/*! (c) Andrea Giammarchi - ISC */
|
|
var self = this || /* istanbul ignore next */ {};
|
|
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;
|
|
}
|
|
};
|
|
}
|