is-implemented.js 474 B

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