This file contains hidden or 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
const memoizeFactory = hashFn => fn => { | |
const memoize = fn => { | |
const cache = {}; | |
return (...args) => { | |
const key = hashFn(args); | |
if (key in cache) { | |
return cache[key]; | |
} |
This file contains hidden or 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
/** | |
* Transforms a function of the form: | |
* fn = (p1, ..., pN) => f(p1, ...pN) | |
* to its curried form: | |
* curried = p1 => p2 => ... => pN => fn(p1, p2, ..., pN); | |
* | |
* @param fn | |
* @returns the curried form of fn | |
*/ | |
const curry = fn => |