configurator.js 1.1 KB

123456789101112131415161718192021222324252627
  1. var hasOwn = require('./internals/has-own-property');
  2. var isArray = require('./internals/is-array');
  3. var isForced = require('./internals/is-forced');
  4. var shared = require('./internals/shared-store');
  5. var data = isForced.data;
  6. var normalize = isForced.normalize;
  7. var USE_FUNCTION_CONSTRUCTOR = 'USE_FUNCTION_CONSTRUCTOR';
  8. var ASYNC_ITERATOR_PROTOTYPE = 'AsyncIteratorPrototype';
  9. var setAggressivenessLevel = function (object, constant) {
  10. if (isArray(object)) for (var i = 0; i < object.length; i++) data[normalize(object[i])] = constant;
  11. };
  12. module.exports = function (options) {
  13. if (typeof options == 'object') {
  14. setAggressivenessLevel(options.useNative, isForced.NATIVE);
  15. setAggressivenessLevel(options.usePolyfill, isForced.POLYFILL);
  16. setAggressivenessLevel(options.useFeatureDetection, null);
  17. if (hasOwn(options, USE_FUNCTION_CONSTRUCTOR)) {
  18. shared[USE_FUNCTION_CONSTRUCTOR] = !!options[USE_FUNCTION_CONSTRUCTOR];
  19. }
  20. if (hasOwn(options, ASYNC_ITERATOR_PROTOTYPE)) {
  21. shared[USE_FUNCTION_CONSTRUCTOR] = options[ASYNC_ITERATOR_PROTOTYPE];
  22. }
  23. }
  24. };