memoize
Call Signature
memoize<
Fn>(getter):Memoized<Fn>
Memoizes a constant or a constant function output. Subsequent calls to the function will not evaluate the given constant function, but uses a cached value instead.
Example
let i = 0const mem = memoize(() => i++)mem()// => 0
mem()// => 0
mem.clear()mem()// => 1Alternatives
Type Parameters
• Fn extends () => any
Parameters
getter
Fn
The constant or constant function.
Returns
Memoized<Fn>
The memoized function to the constant.
Call Signature
memoize<
Fn>(getter,resolver):Memoized<Fn>
Memoizes a constant or a constant function output. Subsequent calls to the function will not evaluate the given constant function, but uses a cached value instead.
Example
let i = 0const mem = memoize(() => i++)mem()// => 0
mem()// => 0
mem.clear()mem()// => 1Alternatives
Type Parameters
• Fn extends (…args) => any
Parameters
getter
Fn
The constant or constant function.
resolver
Resolver<Fn>
The resolver that defines how the constant function should be retrieved.
Returns
Memoized<Fn>
The memoized function to the constant.