@not-govuk/memoize
v0.16.3
Published
Higher-order functions for memoizing pure functions.
Readme
NotGovUK - Memoize
Higher-order functions for memoizing pure functions.
Memoization is a crude optimisation whereby the results of a function are store in memory. It only works for functions that offer referential transparency, meaning that they return the same value for the same input.
Note: Currently, only single-parameter functions are supported.
Using this package
First install the package into your project:
npm install -S @not-govuk/memoizeThen use it in your code as follows:
import memoize from '@not-govuk/memoize';
const myPureFunction = str => str.length;
const memoizedFn = memoize(myPureFunction);
memoizedFn('foo'); // 3Working on this package
Before working on this package you must install its dependencies using the following command:
pnpm installBuilding
npm run buildClean-up
npm run clean