Skip to content

Instantly share code, notes, and snippets.

@safareli
Last active August 29, 2015 14:02
Show Gist options
  • Save safareli/868d787208126aa039a0 to your computer and use it in GitHub Desktop.
Save safareli/868d787208126aa039a0 to your computer and use it in GitHub Desktop.
in memory data store
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