is-implemented.js 614 B

1234567891011121314151617181920
  1. 'use strict';
  2. module.exports = function () {
  3. var weakMap, x;
  4. if (typeof WeakMap !== 'function') return false;
  5. try {
  6. // WebKit doesn't support arguments and crashes
  7. weakMap = new WeakMap([[x = {}, 'one'], [{}, 'two'], [{}, 'three']]);
  8. } catch (e) {
  9. return false;
  10. }
  11. if (String(weakMap) !== '[object WeakMap]') return false;
  12. if (typeof weakMap.set !== 'function') return false;
  13. if (weakMap.set({}, 1) !== weakMap) return false;
  14. if (typeof weakMap.delete !== 'function') return false;
  15. if (typeof weakMap.has !== 'function') return false;
  16. if (weakMap.get(x) !== 'one') return false;
  17. return true;
  18. };