JSPM

@sasidakh/memoizer

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q17661F
  • License MIT

A simple memoizer

Package Exports

  • @sasidakh/memoizer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sasidakh/memoizer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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(n - 1) + fib(n - 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