npm install --save naves
memoize
memoize<[T1, T2, ...], R>(fn);
Creates new function which memoizes the result of fn
. As a cache key memoization function uses JSON.stringified result of arguments provided to memoized function. If one of arguments include circular reference than memoized function can not cache the result and calculates it in every call.
import { memoize } from 'naves';
...
const memoizedFn: (...args: T) => R = memoize<[T1, T2, ...], R>(fn);
memoizedFn(...args);
This project is licensed under the MIT License - see the LICENSE file for details.