Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@sasidakh/memoizer

1.0.0 • Public • Published

memoizer

I was looking for a memoizer that can cache the values of a recursive fibonacci series while it is executing.

I found that specific solutions exists by passing a cache object to the recursive function and using it in the immplementation but nothing generic exists. This is my attempt at writing one.

Usage:

// the fibonacci series using recursion.
const fib = (n) => n > 1 ? fib(- 1) + fib(- 2) : n;
const fibMemo = memoize(fib);
fibMemo(40); // run the test file to see benchmarks

To get benchmarks and a more than trivial test, run :

npm test

Install

npm i @sasidakh/memoizer

DownloadsWeekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

3.1 kB

Total Files

3

Last publish

Collaborators

  • avatar