Installations
npm install @new10com/lru-memoizer
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
8.11.1
NPM Version
5.6.0
Score
70.6
Supply Chain
98.5
Quality
81.7
Maintenance
50
Vulnerability
98.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
new10com
Download Statistics
Total Downloads
37,628
Last Day
1
Last Week
6
Last Month
96
Last Year
871
GitHub Statistics
54 Commits
5 Watching
2 Branches
1 Contributors
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
37,628
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
@new10com/lru-memoizer
Memoize functions results using an lru-cache.
Installation
npm i @new10com/lru-memoizer
Intro
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.
Usage
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
Sync lru-memoizer
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
});
Similar modules
This module is very similar to async-cache, the main difference is the hash
function.
License
MIT 2016 - José F. Romaniello
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
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
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
10 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-hxm2-r34f-qmc5
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-3fx5-fwvr-xrjg
- Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f
Score
1.7
/10
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