1.0.4 • Published 3 years ago
minimoize v1.0.4
minimoize
A very tiny (less than 100 lines!) yet powerful memoizer for JavaScript functions.
Installation
With script tag
<script src="https://unpkg.com/minimoize@1.0.4/dist/index.js"></script>
minimoize
will be defined as global variable.
With ES modules
import minimoize from 'https://unpkg.com/minimoize@1.0.4/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