Skip to content

Commit

Permalink
Added minimum lifetime option and constructor now supports taking num…
Browse files Browse the repository at this point in the history
…ber for capacity as only argument
  • Loading branch information
ktaeyln committed Mar 21, 2018
1 parent b60447f commit b9e01b2
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 45 deletions.
12 changes: 11 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

module "lru-weak-cache" {
declare class LRUWeakCache<V extends object> extends Map<string, V> {
constructor(options: {timeout?:number,capacity?:number,retimeOnAccess?:boolean});
/**
* Construct a new LRUWeakCache instance.
*
* @param options A number specifying the capacity, or a object of options, if nothing is provided, a capacity of 200 is used by default
* @param options.timeout The time in milliseconds an object can exist before being erased
* @param options.capacity The maximum number of items this cache can contain before it starts erasing old ones
* @param options.lifetime The minimum time in milliseconds an item can exist before being allowed to be garbage collected
* @param options.retimeOnAccess Whether or not to reset the timeout timer when an item is accessed
* @param options.reliveOnAccess Whether or not to reset the lifetime timer when an item is accessed
*/
constructor(options: number | {timeout?:number,capacity?:number,lifetime?:number,retimeOnAccess?:boolean,reliveOnAccess?:boolean});
generate(key: string, generator: (key: string, callback: (err: Error, value?: V) => void) => void, callback: (err: Error, value?: V) => void): void;
}
export = LRUWeakCache;
Expand Down
60 changes: 49 additions & 11 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b9e01b2

Please sign in to comment.