debian-mirror-gitlab/core-js/internals/well-known-symbol.js

18 lines
718 B
JavaScript
Raw Normal View History

2019-09-25 13:30:05 +05:30
var global = require('../internals/global');
var shared = require('../internals/shared');
2019-12-04 20:38:33 +05:30
var has = require('../internals/has');
2019-09-25 13:30:05 +05:30
var uid = require('../internals/uid');
var NATIVE_SYMBOL = require('../internals/native-symbol');
2019-12-04 20:38:33 +05:30
var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
2019-09-25 13:30:05 +05:30
2019-12-04 20:38:33 +05:30
var WellKnownSymbolsStore = shared('wks');
2019-09-25 13:30:05 +05:30
var Symbol = global.Symbol;
2019-12-04 20:38:33 +05:30
var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : uid;
2019-09-25 13:30:05 +05:30
module.exports = function (name) {
2019-12-04 20:38:33 +05:30
if (!has(WellKnownSymbolsStore, name)) {
if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];
else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
} return WellKnownSymbolsStore[name];
2019-09-25 13:30:05 +05:30
};