Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 628 Bytes

README.md

File metadata and controls

32 lines (21 loc) · 628 Bytes

Memoize

npm version

A small library to memoize functions for Node.js and web browser.
It supports limiting cache size and governing cache by the performance or frequency of function calls.

Usage

const memoized = memoize.frequency(func,limit);

Example

const memoize = require('./memoize.js');  

const fibonacci = (n) => {
  if (n === 0 || n === 1) {
    return n;
  } else {
    return fibonacci(n - 1) + fibonacci(n - 2);
  }
}

const fib = memoize.performance(fibonacci, 10);
fib(20);