standard-symbols.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. var d = require("d")
  3. , NativeSymbol = require("ext/global-this").Symbol;
  4. module.exports = function (SymbolPolyfill) {
  5. return Object.defineProperties(SymbolPolyfill, {
  6. // To ensure proper interoperability with other native functions (e.g. Array.from)
  7. // fallback to eventual native implementation of given symbol
  8. hasInstance: d(
  9. "", (NativeSymbol && NativeSymbol.hasInstance) || SymbolPolyfill("hasInstance")
  10. ),
  11. isConcatSpreadable: d(
  12. "",
  13. (NativeSymbol && NativeSymbol.isConcatSpreadable) ||
  14. SymbolPolyfill("isConcatSpreadable")
  15. ),
  16. iterator: d("", (NativeSymbol && NativeSymbol.iterator) || SymbolPolyfill("iterator")),
  17. match: d("", (NativeSymbol && NativeSymbol.match) || SymbolPolyfill("match")),
  18. replace: d("", (NativeSymbol && NativeSymbol.replace) || SymbolPolyfill("replace")),
  19. search: d("", (NativeSymbol && NativeSymbol.search) || SymbolPolyfill("search")),
  20. species: d("", (NativeSymbol && NativeSymbol.species) || SymbolPolyfill("species")),
  21. split: d("", (NativeSymbol && NativeSymbol.split) || SymbolPolyfill("split")),
  22. toPrimitive: d(
  23. "", (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill("toPrimitive")
  24. ),
  25. toStringTag: d(
  26. "", (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill("toStringTag")
  27. ),
  28. unscopables: d(
  29. "", (NativeSymbol && NativeSymbol.unscopables) || SymbolPolyfill("unscopables")
  30. )
  31. });
  32. };