Install
yarn add lru-memoize-map
Usage
- exports 'memoize' function as default module
- memoize(lruCacheSize, options)
- @lruCacheSize: the number of entries to hold in the cache at a given time
- @options: {multiArgs: (bool), coalesceWith: (function)} see below for examples
// Single-argument memoizationconst memoizer = { // do some work } // Multi-argument memoization// This option creates an array from the arguments and uses that as the Map// key. All entries in the cache must be checked for matches on the argument// array in this case each time the cache is utilized.const multiArgsMemoizer = { // do some work } // Multi-argument memoization with JSON serializable arguments// the 'coalasceWith' option is used to coalesce multiple arguments// into a single argumentconst jsonArgMemoizer = { // do some work }