is-implemented.js 548 B

1234567891011121314151617181920
  1. "use strict";
  2. var global = require("ext/global-this")
  3. , validTypes = { object: true, symbol: true };
  4. module.exports = function () {
  5. var Symbol = global.Symbol;
  6. var symbol;
  7. if (typeof Symbol !== "function") return false;
  8. symbol = Symbol("test symbol");
  9. try { String(symbol); }
  10. catch (e) { return false; }
  11. // Return 'true' also for polyfills
  12. if (!validTypes[typeof Symbol.iterator]) return false;
  13. if (!validTypes[typeof Symbol.toPrimitive]) return false;
  14. if (!validTypes[typeof Symbol.toStringTag]) return false;
  15. return true;
  16. };