Skip to content

Instantly share code, notes, and snippets.

@erights
Last active January 13, 2017 19:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erights/d318decf3813a2d7ca70ab8fe5bea2b3 to your computer and use it in GitHub Desktop.
Save erights/d318decf3813a2d7ca70ab8fe5bea2b3 to your computer and use it in GitHub Desktop.
microses-to-microses-for-persistence
const makeAddr = (x => (y => x + y));
const wm = makeWeakMap();
const makeAddr = (x => {
const fn = (y => x + y);
wm.set(fn, {get x() { return x; });
return fn;
});
const add5 = makeAddr(5);
add5(3); // 8
wm.get(add5).x; // 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment