conditional-map
v0.0.1
Published
You can use it with [p-memoize](https://github.com/sindresorhus/p-memoize) to control caching by result
Downloads
4
Readme
conditional-map
You can use it with p-memoize to control caching by result
Install
npm install conditional-map
Usage
import pMemoize from 'p-memoize';
import ConditionalMap from 'conditional-map';
const fixture = async () => index++;
const condition = (value: number) => value % 2 !== 0;
const memoized = pMemoize(fixture, {
cache: new ConditionalMap(condition)
});
memoized().then(() => console.log(value)) // 0
memoized().then(() => console.log(value)) // 1
memoized().then(() => console.log(value)) // 1