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

  1. fn*-Function

    The function to memoize his result

Return

  1. -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 cache