UNPKG

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