Skip to content

Instantly share code, notes, and snippets.

@wdiasvargas
Created June 21, 2017 05:04
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 wdiasvargas/47c5c42c0adc885a312eda462822188d to your computer and use it in GitHub Desktop.
Save wdiasvargas/47c5c42c0adc885a312eda462822188d to your computer and use it in GitHub Desktop.
memoization
/**
* Created in 20/06/2017.
* Author: William Dias Vargas
* Github: @wdiasvargas
*/
"use strict";
export default (fn, cache = {}) => (x) => (x in cache) ? cache[x] : cache[x] = fn(x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment