configurator.js 1.1 KB

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