-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
55 lines (55 loc) · 1.34 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*! (c) Andrea Giammarchi - ISC */
var self = this || {};
try { self.Set = Set; }
catch (Set) {
(function (i, dPs) {'use strict';
var proto = dPs(Set.prototype, {size: {
configurable: true,
get: function () {
return this._v.length;
}
}});
proto.add = function (value) {
if (!has(this, value))
this._v.push(value);
return this;
};
proto.clear = function () {
var length = this._v.length;
this._v.splice(0, length);
};
proto.delete = function (value) {
return has(this, value) && !!this._v.splice(i, 1);
};
proto.entries = function () {
return this._v.map(pair);
};
proto.forEach = function (callback, context) {
this._v.forEach(
function (value, i) {
callback.call(context, value, value, this);
},
this
);
};
proto.has = function (key) {
return has(this, key);
};
proto.keys = proto.values = function () {
return this._v.slice(0);
};
self.Set = Set;
function Set(iterable) {
dPs(this, {_v: {value: []}});
if (iterable)
iterable.forEach(this.add, this);
}
function has(self, value) {
i = self._v.indexOf(value);
return -1 < i;
}
function pair(value) {
return [value, value];
}
}(0, Object.defineProperties));
}