You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
xxdj1/node_modules/core-js/modules/esnext.symbol.is-well-known.js

36 lines
1.6 KiB

var $ = require('../internals/export');
var shared = require('../internals/shared');
var getBuiltIn = require('../internals/get-built-in');
var uncurryThis = require('../internals/function-uncurry-this');
var isSymbol = require('../internals/is-symbol');
var wellKnownSymbol = require('../internals/well-known-symbol');
var Symbol = getBuiltIn('Symbol');
var $isWellKnown = Symbol.isWellKnown;
var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames');
var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf);
var WellKnownSymbolsStore = shared('wks');
for (var i = 0, symbolKeys = getOwnPropertyNames(Symbol), symbolKeysLength = symbolKeys.length; i < symbolKeysLength; i++) {
// some old engines throws on access to some keys like `arguments` or `caller`
try {
var symbolKey = symbolKeys[i];
if (isSymbol(Symbol[symbolKey])) wellKnownSymbol(symbolKey);
} catch (error) { /* empty */ }
}
// `Symbol.isWellKnown` method
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknown
// We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected
$({ target: 'Symbol', stat: true, forced: true }, {
isWellKnown: function isWellKnown(value) {
if ($isWellKnown && $isWellKnown(value)) return true;
try {
var symbol = thisSymbolValue(value);
for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) {
if (WellKnownSymbolsStore[keys[j]] == symbol) return true;
}
} catch (error) { /* empty */ }
return false;
}
});