1.0.1-alpha • Published 3 years ago
simple-cache-function v1.0.1-alpha
simple-cache-function
Saves the result of the function. With the same arguments, the function returns the stored result.
Install
Install with npm:
$ npm install --save simple-cache-function
Usage
const { memoize } = require('simple-cache-function');
function fibonacci(n) {
if (n <= 1) {
return 1
}
return fibonacci(n - 1) + fibonacci(n - 2);
}
const fibonacciMemo = memoize(fibonacci);
console.log(fibonacciMemo(6)); //=> 13
Author
Rostislav Kalyuzhny
1.0.1-alpha
3 years ago