/cacher

Primary LanguageJavaScript

cacher

Cache a function's results by storing them. You may assume that the function only takes primitives as arguments.

The function should return a function that, when called, will check if it has already computed the result and return that value instead if possible.

Example:
cacheAdd = myFunction(add);
add(1,2) = 3
cacheAdd(1,2) = 3 --> executes add function
cacheAdd(1,2) = 3 --> returns from cache
cacheAdd(2,2) = 4--> executes add function

Run Tests

npm install

npm run test