Last active
August 29, 2015 14:02
-
-
Save safareli/868d787208126aa039a0 to your computer and use it in GitHub Desktop.
in memory data store
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 storer(key, val) { | |
if (arguments.length === 1) | |
return this[key]; | |
else if (arguments.length === 0) | |
return this; | |
if (typeof val === "function") | |
return function () { | |
return val.apply(storer.bind(this, key), arguments); | |
}.bind(this); | |
setTimeout(console.log.bind(console, this), 1); | |
return this[key] = val; | |
} | |
var store = storer.bind({}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment