A memoization library that caches the result of the different arguments
MIT License
A memoization library that caches the result of the different arguments
npm install memoize-fn
# or use yarn
yarn add memoize-fn
import memoizeFn from 'memoize-fn'
import { withCtx, robust } from 'memoize-fn'
let count = 1
const fn = memoizeFn(() => count++)
fn() // => 1
fn() // => 1
fn('new argument') // => 2
fn() // => 1
count // => 3
Memoize function that caches the result of the different arguments.
fn
{Function}options
Object {MemoizeOptions} (optional, default {}
)
options.once
(optional, default false
)options.eq
(optional, default (prevArgs,newArgs)=>shallowEqual(prevArgs,newArgs)
)options.cache
(optional, default new Map()
)options.skipEqualThis
(optional, default true
)Returns any memoizeFn {Function}
Memoize function that caches the result of the different arguments and with context
fn
{Function}opts
{MemoizeOptions}Returns CtxFunction
Memoize function that caches the result of the different arguments and resets memoize function when catches error asynchronously.
fn
{Function}opts
{MemoizeOptions}Returns CtxFunction
Type: {}
once
{boolean} - Only cache once like memoize-one (optional, default false
)eq
{(prevArgs, newArgs) => boolean} (optional, default shallowEqual
)cache
{Map} (optional, default newMap()
)skipEqualThis
{boolean} (optional, default true
)Type: Function
reset
{Function} - Resets cacheunCache
{Function} - Disables cachegit checkout -b feature-new
or git checkout -b fix-which-bug
git commit -am 'feat: some description (close #123)'
or git commit -am 'fix: some description (fix #123)'
git push
This library is written and maintained by imcuttle, [email protected].
MIT - imcuttle 🐟