-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
71 lines (71 loc) · 1.73 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*! (c) Andrea Giammarchi - ISC */
var self = this || {};
/* istanbul ignore next */
try { self.Map = Map; }
catch (Map) {
(function (i, dPs) {'use strict';
var proto = dPs(Map.prototype, {size: {
configurable: true,
get: function () {
return this._k.length;
}
}});
proto.clear = function () {
var length = this._k.length;
this._k.splice(0, length);
this._v.splice(0, length);
};
proto.delete = function (key) {
var had = has(this, key);
if (had) {
this._k.splice(i, 1);
this._v.splice(i, 1);
}
return had;
};
proto.entries = function () {
return this._k.map(pair, this._v);
};
proto.forEach = function (callback, context) {
this._k.forEach(
function (key, i) {
callback.call(context, this._v[i], key, this);
},
this
);
};
proto.get = function (key) {
return has(this, key) ? this._v[i] : void 0;
};
proto.has = function (key) {
return has(this, key);
};
proto.keys = function () {
return this._k.slice(0);
};
proto.set = function (key, value) {
this._v[has(this, key) ? i : (this._k.push(key) - 1)] = value;
return this;
};
proto.values = function () {
return this._v.slice(0);
};
self.Map = Map;
return Map;
function Map(iterable) {
dPs(this, {_k: {value: []}, _v: {value: []}});
if (iterable)
iterable.forEach(add, this);
}
function add(pair) {
this.set(pair[0], pair[1]);
}
function has(self, value) {
i = self._k.indexOf(value);
return -1 < i;
}
function pair(v, i) {
return [v, this[i]];
}
}(0, Object.defineProperties));
}