Gathering detailed insights and metrics for lru-weak-cache
Gathering detailed insights and metrics for lru-weak-cache
Gathering detailed insights and metrics for lru-weak-cache
Gathering detailed insights and metrics for lru-weak-cache
A caching Map<string, V extends object> that deletes the least-recently-used items with weak references and async generation. Inspired by lru-cache.
npm install lru-weak-cache
Typescript
Module System
Node Version
NPM Version
70.9
Supply Chain
93.5
Quality
75.1
Maintenance
100
Vulnerability
98.6
License
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
15 Commits
2 Watchers
6 Branches
1 Contributors
Updated on Jan 23, 2021
Latest Version
0.3.3
Package Id
lru-weak-cache@0.3.3
Unpacked Size
65.89 kB
Size
13.90 kB
File Count
9
NPM Version
6.14.11
Node Version
14.15.4
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
7
A caching Map<string, V extends object> that deletes the least-recently-used items with weak references and async generation. Inspired by lru-cache.
1npm install lru-weak-cache
1export = class LRUWeakCache<V extends object> extends Map<string, V> { 2 /** 3 * Construct a new LRUWeakCache instance. 4 * 5 * @param options A number specifying the capacity, or a object of options, if nothing is provided, a capacity of 200 is used by default 6 * @param options.minAge The minimum time in milliseconds an item can exist before being allowed to be garbage collected 7 * @param options.maxAge The maximum time in milliseconds an object can exist before being erased, this should be higher than minAge or minAge will have no affect 8 * @param options.capacity The maximum number of items this cache can contain before it starts erasing old ones 9 * @param options.resetTimersOnAccess Whether or not to reset the minAge and maxAge timers when an item is accessed 10 */ 11 constructor(options: number | {minAge?:number,maxAge?:number,capacity?:number,resetTimersOnAccess?:boolean}); 12 /** 13 * Asynchroniously generate a value for a given key with a callback. 14 * This method can be called multiple times, or in conjunction with {@see generateMulti} and only calls the generator once per key for the specified caching settings. 15 * 16 * @param key The key to use 17 * @param generator The generator to generate the value using 18 * @param callback The callback to call when finished 19 */ 20 generate(key: string, generator: CacheGenerator<V>, callback: (err: Error, value?: V) => void): Cancel<V>; 21 /** 22 * Asynchroniously generate multiple values for a given key with a callback. 23 * This method can be called multiple times, or in conjunction with {@see generate} and only calls the generator once per key for the specified caching settings. 24 * 25 * @param keys The keys to use 26 * @param generator The generator to generate the values using 27 * @param callback The callback to call when finished 28 */ 29 generateMulti(keys: string[], generator: CacheMultiGenerator<V>, callback: (err: Error, ret?: {[key: string]: V}) => void): Cancel<{[index:string]:V}>; 30 /** 31 * Efficiently set multiple values while maintaining the capacity and other settings 32 */ 33 setMulti(data: {[index: string]: V}): this; 34 /** 35 * Trim least-recently-used items from this map. 36 * 37 * @param by The amount to trim by 38 */ 39 trim(by: number): this; 40} 41 42interface VCancel { 43 (): void 44} 45interface Cancel<V> { 46 (dataOrError?: V | Error): void 47} 48interface CacheGenerator<V extends object> { 49 (key: string, callback: (err: Error, value?: V) => void): VCancel | undefined; 50} 51interface CacheMultiGenerator<V extends object> { 52 (keys: string[], callback: (err: Error, ret?: {[key: string]: V}) => void): VCancel | undefined; 53}
1import LRUWeakCache = require("lru-weak-cache"); 2 3var cache = new LRUWeakCache<any>(); // Defaults to a capacity of 200 4cache = new LRUWeakCache<any>({maxAge:3600000}); // Nothing older than 1 hour 5cache = new LRUWeakCache<any>({minAge:600000}); // 10 minutes before garbage collection 6cache = new LRUWeakCache<any>(800); // Capacity of 800 7 8// Everything from Map<string, ?> is implemented
node-lru-weak-cache is licensed under Apache License 2.0
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/15 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
17 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
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