-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (42 loc) · 937 Bytes
/
index.js
File metadata and controls
42 lines (42 loc) · 937 Bytes
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
/*! (c) Andrea Giammarchi - ISC */
var self = this || {};
try { self.Map = Map; }
catch (Map) {
self.Map = function Map() {
var i = 0;
var k = [];
var v = [];
return {
delete: function (key) {
var had = contains(key);
if (had) {
k.splice(i, 1);
v.splice(i, 1);
}
return had;
},
forEach: function forEach(callback, context) {
k.forEach(
function (key, i) {
callback.call(context, v[i], key, this);
},
this
);
},
get: function get(key) {
return contains(key) ? v[i] : void 0;
},
has: function has(key) {
return contains(key);
},
set: function set(key, value) {
v[contains(key) ? i : (k.push(key) - 1)] = value;
return this;
}
};
function contains(v) {
i = k.indexOf(v);
return -1 < i;
}
};
}