configurator.js 1.0 KB

1234567891011121314151617181920212223
  1. var has = require('./internals/has');
  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 (has(options, USE_FUNCTION_CONSTRUCTOR)) shared[USE_FUNCTION_CONSTRUCTOR] = !!options[USE_FUNCTION_CONSTRUCTOR];
  18. if (has(options, ASYNC_ITERATOR_PROTOTYPE)) shared[USE_FUNCTION_CONSTRUCTOR] = options[ASYNC_ITERATOR_PROTOTYPE];
  19. }
  20. };