is-forced.js 634 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var fails = require('../internals/fails');
  3. var isCallable = require('../internals/is-callable');
  4. var replacement = /#|\.prototype\./;
  5. var isForced = function (feature, detection) {
  6. var value = data[normalize(feature)];
  7. return value === POLYFILL ? true
  8. : value === NATIVE ? false
  9. : isCallable(detection) ? fails(detection)
  10. : !!detection;
  11. };
  12. var normalize = isForced.normalize = function (string) {
  13. return String(string).replace(replacement, '.').toLowerCase();
  14. };
  15. var data = isForced.data = {};
  16. var NATIVE = isForced.NATIVE = 'N';
  17. var POLYFILL = isForced.POLYFILL = 'P';
  18. module.exports = isForced;