1.0.2 • Published 12 months ago

pico-memoize v1.0.2

Weekly downloads
22
License
GPL-3.0-only
Repository
github
Last release
12 months ago

pico-memoize

A tiny Javascript memoization library.

Usage

//CJS
const memoized = require('pico-memoize');
//ESM
import memoized from 'pico-memoize';
//If using it in the browser, it globalizes the memoized function
function sumPrecise(array){
    console.log(array);
    return array.reduce((a,b)=>a+b,0);
}
sumPrecise = memoized(sumPrecise);
sumPrecise([1,2,3]); //logs [1,2,3], returns 6
sumPrecise([1,2,3]); //returns 6 without logging anything

function deepEqual(a,b){
    // memoization has more uses than you think!
    let wrapper = memoized(Object);
    return wrapper(a) === wrapper(b);
}
1.0.2

12 months ago

1.0.1

4 years ago

1.0.0

4 years ago