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.
25 lines
1.0 KiB
25 lines
1.0 KiB
3 years ago
|
var global = require('../internals/global');
|
||
|
var shared = require('../internals/shared');
|
||
|
var hasOwn = require('../internals/has-own-property');
|
||
|
var uid = require('../internals/uid');
|
||
|
var NATIVE_SYMBOL = require('../internals/native-symbol');
|
||
|
var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
|
||
|
|
||
|
var WellKnownSymbolsStore = shared('wks');
|
||
|
var Symbol = global.Symbol;
|
||
|
var symbolFor = Symbol && Symbol['for'];
|
||
|
var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
|
||
|
|
||
|
module.exports = function (name) {
|
||
|
if (!hasOwn(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
|
||
|
var description = 'Symbol.' + name;
|
||
|
if (NATIVE_SYMBOL && hasOwn(Symbol, name)) {
|
||
|
WellKnownSymbolsStore[name] = Symbol[name];
|
||
|
} else if (USE_SYMBOL_AS_UID && symbolFor) {
|
||
|
WellKnownSymbolsStore[name] = symbolFor(description);
|
||
|
} else {
|
||
|
WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
|
||
|
}
|
||
|
} return WellKnownSymbolsStore[name];
|
||
|
};
|