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.
36 lines
1.6 KiB
36 lines
1.6 KiB
4 weeks ago
|
'use strict';
|
||
|
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 $isWellKnownSymbol = Symbol.isWellKnownSymbol;
|
||
|
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.isWellKnownSymbol` method
|
||
|
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol
|
||
|
// We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected
|
||
|
module.exports = function isWellKnownSymbol(value) {
|
||
|
if ($isWellKnownSymbol && $isWellKnownSymbol(value)) return true;
|
||
|
try {
|
||
|
var symbol = thisSymbolValue(value);
|
||
|
for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) {
|
||
|
// eslint-disable-next-line eqeqeq -- polyfilled symbols case
|
||
|
if (WellKnownSymbolsStore[keys[j]] == symbol) return true;
|
||
|
}
|
||
|
} catch (error) { /* empty */ }
|
||
|
return false;
|
||
|
};
|