UNPKG

@ungap/essential-weakset

Version:

Essential WeakSet for legacy browsers.

25 lines (24 loc) 715 B
/*! (c) Andrea Giammarchi - ISC */ var self = {}; try { self.WeakSet = WeakSet; } catch (WeakSet) { (function (id, dP) { var proto = WeakSet.prototype; proto.add = function (object) { if (!this.has(object)) dP(object, this._, {value: true, configurable: true}); return this; }; proto.has = function (object) { return this.hasOwnProperty.call(object, this._); }; proto.delete = function (object) { return this.has(object) && delete object[this._]; }; self.WeakSet = WeakSet; function WeakSet() {'use strict'; dP(this, '_', {value: '_@ungap/weakmap' + id++}); } }(Math.random(), Object.defineProperty)); } export default self.WeakSet;