shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
memoize
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.function
This function can be used to memorize a function call result in order to save memory. This is just a “proxy” of the “memoizee” package.
Params
- fn*-Function
The function to memoize his result
Return
- -Any
The memoized function result
Example
import { memoize } from '@blackbyte/sugar/function';
const fn = memoize(function(text) => {
return `Hello ${text}`;
});
const result = fn('world'); // first execution. no cache
const result1 = fn('plop'); // first execution with this argument, no cache
const result2 = fn('world'); // taken from cacheAuthor
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space