Skip to content

Instantly share code, notes, and snippets.

@amatiasq
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amatiasq/b1544c1e92df9cf055ea to your computer and use it in GitHub Desktop.
Save amatiasq/b1544c1e92df9cf055ea to your computer and use it in GitHub Desktop.
(function() {
'use strict';
if (window.Map) return;
window.Map = FakeMap;
function FakeMap() {
this._keys = [];
this._values = [];
}
FakeMap.prototype = {
has: function(key) {
return this._keys.indexOf(key) !== -1;
},
get: function(key) {
var index = this._keys.indexOf(key);
if (index === -1) return;
return this._values[index];
},
set: function(key, value) {
var index = this._keys.indexOf(key);
if (index === -1)
index = this._keys.length;
this._keys[index] = key;
this._values[index] = value;
},
delete: function(key) {
var index = this._keys.indexOf(key);
if (index === -1) return;
this._keys.splice(index, 1);
this._values.splice(index, 1);
},
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment