minimoize
v1.0.4
Published
A tiny memoizer for JavaScript functions
Downloads
4
Readme
minimoize
A very tiny (less than 100 lines!) yet powerful memoizer for JavaScript functions.
Installation
With script tag
<script src="https://unpkg.com/[email protected]/dist/index.js"></script>
minimoize
will be defined as global variable.
With ES modules
import minimoize from 'https://unpkg.com/[email protected]/dist/index.mjs';
Usage
function fn(arg) {
// my complex function
return { hello: 'false', test: arg };
}
fn(1) === fn(1); // false ; different objects with same content
// > The magic <
fn = minimoize(fn);
// Now, fn will memoize depending args
fn(1) === fn(1); // true ; same objects