Gathering detailed insights and metrics for @new10com/lru-memoizer
Gathering detailed insights and metrics for @new10com/lru-memoizer
Gathering detailed insights and metrics for @new10com/lru-memoizer
Gathering detailed insights and metrics for @new10com/lru-memoizer
npm install @new10com/lru-memoizer
Typescript
Module System
Node Version
NPM Version
70.6
Supply Chain
98.5
Quality
81.7
Maintenance
50
Vulnerability
98.6
License
JavaScript (100%)
Total Downloads
37,628
Last Day
1
Last Week
6
Last Month
96
Last Year
871
54 Commits
5 Watching
2 Branches
1 Contributors
Latest Version
1.13.6
Package Id
@new10com/lru-memoizer@1.13.6
Unpacked Size
29.90 kB
Size
6.30 kB
File Count
17
NPM Version
5.6.0
Node Version
8.11.1
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
6
Compared to previous week
Last month
57.4%
96
Compared to previous month
Last year
-73.5%
871
Compared to previous year
Memoize functions results using an lru-cache.
npm i @new10com/lru-memoizer
Forked from https://github.com/jfromaniello/lru-memoizer
This module uses an lru-cache internally to cache the results of an async function.
The load
function can have N parameters and the last one must be a callback. The callback should be an errback (first parameter is err
).
The hash
function purpose is generate a custom hash for storing results. It has all the arguments applied to it minus the callback, and must return an string synchronous.
The freeze
option (defaults to false) allows you to deep-freeze the result of the async function.
The clone
option (defaults to false) allows you to deep-clone the result every time is returned from the cache.
1 2var memoizer = require('@new10com/lru-memoizer'); 3 4var memoizedGet = memoizer({ 5 //defines how to load the resource when 6 //it is not in the cache. 7 load: function (options, callback) { 8 request.get(options, callback); 9 }, 10 11 //defines how to create a cache key from the params. 12 hash: function (options) { 13 return options.url + qs.stringify(options.qs); 14 }, 15 16 //all other params for the LRU cache. 17 max: 100, 18 maxAge: 1000 * 60 19}); 20 21memoizedGet({ 22 url: 'https://google.com', 23 qs: { foo: 123 } 24}, function (err, result, body) { 25 //console.log(body); 26}) 27
Use memoizer.sync
to cache things that are slow to calculate or methods returning promises.
var memoizer = require('@new10com/lru-memoizer');
var memoizedGet = memoizer.sync({
//defines how to load the resource when
//it is not in the cache.
load: function (params) {
//return something_hard_to_compute;s
},
//defines how to create a cache key from the params.
hash: function (params) {
return params.foo;
},
//all other params for the LRU cache.
max: 100,
maxAge: 1000 * 60
});
This module is very similar to async-cache, the main difference is the hash
function.
MIT 2016 - José F. Romaniello
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
project is archived
Details
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More