memoizee
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
d | 1.0.2 | 13.88 kB | ISC | prod | 1 |
es5-ext | 0.10.64 | 365.2 kB | ISC | prod | 1 |
es6-weak-map | 2.0.3 | 5.09 kB | ISC | prod | 1 |
event-emitter | 0.3.5 | 7.41 kB | MIT | prod | 1 |
is-promise | 2.2.2 | 1.51 kB | MIT | prod | |
lru-queue | 0.1.0 | 2.68 kB | MIT | prod | 1 |
next-tick | 1.1.0 | 3.67 kB | ISC | prod | |
timers-ext | 0.1.7 | 5.3 kB | ISC | prod | 1 |
Memoizee is a complete memoize or cache solution for JavaScript. It helps in saving memory or CPU cycles in operations that are repeated. With this tool, you don't need to serialize to work with any type of function arguments and it is compatible with any length of function arguments The package provides support for promises and asynchronous functions, and offers a "Primitive mode" that assures fast performance when arguments are convertible to strings. It also offers a "WeakMap based mode" for garbage collection-friendly configuration, a manual cache clearance or clearance after a specific timeout, and size limitation options for the cache. It also has a range of other capabilities covered by over 500 unit tests.
To use Memoizee, you first need to install it in your project path. You do this by running the command npm install memoizee
in your terminal. Following that, you import it into your JavaScript file with var memoize = require("memoizee");
.
Then, you declare your function and pass it to the memoize
method. For instance:
var memoize = require("memoizee");
var fn = function(one, two, three) {
/* ... */
};
memoized = memoize(fn);
memoized("foo", 3, "bar");
memoized("foo", 3, "bar"); // Cache hit
In the above code, the function fn
is memoized and it takes three arguments. The memoized function is then invoked with "foo", 3, "bar" as arguments. On the next invocation with the same arguments, memoization is triggered and the result is fetched from the cache.
The Memoizee documentation can be found in the README file on its GitHub repository page. The documentation gives detailed insight into its features, configuration options, and usage examples. Users can learn about different operation modes, customization options, and various other functionalities of this tool from this comprehensive guide.