-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (34 loc) · 1019 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*! (c) Andrea Giammarchi - ISC */
var self = this || {};
try { self.WeakMap = WeakMap; }
catch (WeakMap) {
// this could be better but 90% of the time
// it's everything developers need as fallback
self.WeakMap = (function (id, Object) {'use strict';
var dP = Object.defineProperty;
var hOP = Object.hasOwnProperty;
var proto = WeakMap.prototype;
proto.delete = function (key) {
return this.has(key) && delete key[this._];
};
proto.get = function (key) {
return this.has(key) ? key[this._] : void 0;
};
proto.has = function (key) {
return hOP.call(key, this._);
};
proto.set = function (key, value) {
dP(key, this._, {configurable: true, value: value});
return this;
};
return WeakMap;
function WeakMap(iterable) {
dP(this, '_', {value: '_@ungap/weakmap' + id++});
if (iterable)
iterable.forEach(add, this);
}
function add(pair) {
this.set(pair[0], pair[1]);
}
}(Math.random(), Object));
}