well-known-symbol.js 752 B

1234567891011121314151617
  1. var global = require('../internals/global');
  2. var shared = require('../internals/shared');
  3. var has = require('../internals/has');
  4. var uid = require('../internals/uid');
  5. var NATIVE_SYMBOL = require('../internals/native-symbol');
  6. var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
  7. var WellKnownSymbolsStore = shared('wks');
  8. var Symbol = global.Symbol;
  9. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  10. module.exports = function (name) {
  11. if (!has(WellKnownSymbolsStore, name)) {
  12. if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];
  13. else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  14. } return WellKnownSymbolsStore[name];
  15. };