Node-Red configuration
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.

symbol-is-well-known.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. var shared = require('../internals/shared');
  3. var getBuiltIn = require('../internals/get-built-in');
  4. var uncurryThis = require('../internals/function-uncurry-this');
  5. var isSymbol = require('../internals/is-symbol');
  6. var wellKnownSymbol = require('../internals/well-known-symbol');
  7. var Symbol = getBuiltIn('Symbol');
  8. var $isWellKnownSymbol = Symbol.isWellKnownSymbol;
  9. var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames');
  10. var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf);
  11. var WellKnownSymbolsStore = shared('wks');
  12. for (var i = 0, symbolKeys = getOwnPropertyNames(Symbol), symbolKeysLength = symbolKeys.length; i < symbolKeysLength; i++) {
  13. // some old engines throws on access to some keys like `arguments` or `caller`
  14. try {
  15. var symbolKey = symbolKeys[i];
  16. if (isSymbol(Symbol[symbolKey])) wellKnownSymbol(symbolKey);
  17. } catch (error) { /* empty */ }
  18. }
  19. // `Symbol.isWellKnownSymbol` method
  20. // https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol
  21. // We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected
  22. module.exports = function isWellKnownSymbol(value) {
  23. if ($isWellKnownSymbol && $isWellKnownSymbol(value)) return true;
  24. try {
  25. var symbol = thisSymbolValue(value);
  26. for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) {
  27. // eslint-disable-next-line eqeqeq -- polyfilled symbols case
  28. if (WellKnownSymbolsStore[keys[j]] == symbol) return true;
  29. }
  30. } catch (error) { /* empty */ }
  31. return false;
  32. };