{"library":"memoizerific","title":"Memoizerific","description":"Memoizerific is a fast, small, and efficient JavaScript memoization library designed to cache function results, preventing re-execution for identical arguments. Currently at version 1.11.3, it receives regular minor updates, with recent changes focusing on package configuration and documentation. A key differentiator is its use of JavaScript's native `Map()` object (with a performant polyfill where unavailable) for instant lookups, avoiding costly serialization or string manipulation common in other memoization approaches. It supports multiple complex arguments and incorporates Least-Recently-Used (LRU) caching, allowing developers to specify a limit on the number of results stored. The library is built for compatibility across both browser and Node.js environments and is particularly useful in scenarios like Redux for deriving data on the fly. Its small footprint (1kb min/gzip) makes it a lightweight choice.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install memoizerific"],"cli":null},"imports":["import memoizerific from 'memoizerific'","const memoizerific = require('memoizerific')","const memoized = memoizerific(50)(myFunction);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import memoizerific from 'memoizerific';\n\n// memoize the 50 most recent argument combinations of our function\nconst memoized = memoizerific(50)(function(arg1, arg2, arg3) {\n    // Simulate a long expensive call\n    console.log(`Processing with args: ${arg1}, ${arg2}, ${arg3}`);\n    let sum = 0;\n    for(let i=0; i<1000000; i++) sum += i; // busy loop\n    return `Result for ${arg1}, ${arg2}, ${arg3}: ${sum}`;\n});\n\nconsole.log(memoized(1, 2, 3)); // that took long to process\nconsole.log(memoized(1, 2, 3)); // this one was instant!\n\nconst \n    complexArg1 = { a: { b: { c: 99 }}}, \n    complexArg2 = [{ z: 1}, { q: [{ x: 3 }]}],\n    complexArg3 = new Set(); \n\nconsole.log(memoized(complexArg1, complexArg2, complexArg3)); // slow\nconsole.log(memoized(complexArg1, complexArg2, complexArg3)); // instant!","lang":"javascript","description":"This quickstart demonstrates how to initialize Memoizerific with an LRU cache limit and memoize a function. It shows cache hits for identical primitive and complex arguments (same object instance).","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}