is-implemented.js 621 B

123456789101112131415161718192021
  1. "use strict";
  2. module.exports = function () {
  3. var weakMap, obj;
  4. if (typeof WeakMap !== "function") return false;
  5. try {
  6. // WebKit doesn't support arguments and crashes
  7. weakMap = new WeakMap([[obj = {}, "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(obj) !== "one") return false;
  17. return true;
  18. };