Last active
August 29, 2015 14:23
-
-
Save amatiasq/b1544c1e92df9cf055ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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