@types/lru-cache
Advanced tools
Comparing version 2.5.32 to 4.0.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for lru-cache v2.5.0 | ||
// Type definitions for lru-cache v4.0 | ||
// Project: https://github.com/isaacs/node-lru-cache | ||
@@ -12,6 +12,44 @@ // Definitions by: Bart van der Schoor <https://github.com/Bartvds> | ||
interface Options<T> { | ||
/** | ||
* The maximum size of the cache, checked by applying the length | ||
* function to all values in the cache. Not setting this is kind of silly, | ||
* since that's the whole purpose of this lib, but it defaults to `Infinity`. | ||
*/ | ||
max?: number; | ||
/** | ||
* Maximum age in ms. Items are not pro-actively pruned out as they age, | ||
* but if you try to get an item that is too old, it'll drop it and return | ||
* undefined instead of giving it to you. | ||
*/ | ||
maxAge?: number; | ||
/** | ||
* Function that is used to calculate the length of stored items. | ||
* If you're storing strings or buffers, then you probably want to do | ||
* something like `function(n, key){return n.length}`. The default | ||
* is `function(){return 1}`, which is fine if you want to store | ||
* `max` like-sized things. The item is passed as the first argument, | ||
* and the key is passed as the second argumnet. | ||
*/ | ||
length?: (value: T) => number; | ||
/** | ||
* Function that is called on items when they are dropped from the cache. | ||
* This can be handy if you want to close file descriptors or do other | ||
* cleanup tasks when items are no longer accessible. Called with `key, value`. | ||
* It's called before actually removing the item from the internal cache, | ||
* so if you want to immediately put it back in, you'll have to do that in | ||
* a `nextTick` or `setTimeout` callback or it won't do anything. | ||
*/ | ||
dispose?: (key: any, value: T) => void; | ||
/** | ||
* By default, if you set a `maxAge`, it'll only actually pull stale items | ||
* out of the cache when you `get(key)`. (That is, it's not pre-emptively | ||
* doing a `setTimeout` or anything.) If you set `stale:true`, it'll return | ||
* the stale value before deleting it. If you don't set this, then it'll | ||
* return `undefined` when you try to get a stale entry, | ||
* as if it had already been deleted. | ||
*/ | ||
stale?: boolean; | ||
@@ -21,14 +59,91 @@ } | ||
interface Cache<T> { | ||
/** | ||
* Will update the "recently used"-ness of the key. They do what you think. | ||
* `maxAge` is optional and overrides the cache `maxAge` option if provided. | ||
*/ | ||
set(key: any, value: T, maxAge?: number): void; | ||
/** | ||
* Will update the "recently used"-ness of the key. They do what you think. | ||
* `maxAge` is optional and overrides the cache `maxAge` option if provided. | ||
* | ||
* If the key is not found, will return `undefined`. | ||
*/ | ||
get(key: any): T; | ||
/** | ||
* Returns the key value (or `undefined` if not found) without updating | ||
* the "recently used"-ness of the key. | ||
* | ||
* (If you find yourself using this a lot, you might be using the wrong | ||
* sort of data structure, but there are some use cases where it's handy.) | ||
*/ | ||
peek(key: any): T; | ||
/** | ||
* Check if a key is in the cache, without updating the recent-ness | ||
* or deleting it for being stale. | ||
*/ | ||
has(key: any): boolean | ||
/** | ||
* Deletes a key out of the cache. | ||
*/ | ||
del(key: any): void; | ||
/** | ||
* Clear the cache entirely, throwing away all values. | ||
*/ | ||
reset(): void; | ||
/** | ||
* Manually iterates over the entire cache proactively pruning old entries. | ||
*/ | ||
prune(): void; | ||
/** | ||
* Just like `Array.prototype.forEach`. Iterates over all the keys in the cache, | ||
* in order of recent-ness. (Ie, more recently used items are iterated over first.) | ||
*/ | ||
forEach(iter: (value: T, key: any, cache: Cache<T>) => void, thisp?: any): void; | ||
/** | ||
* The same as `cache.forEach(...)` but items are iterated over in reverse order. | ||
* (ie, less recently used items are iterated over first.) | ||
*/ | ||
rforEach(iter: (value: T, key: any, cache: Cache<T>) => void, thisp?: any): void; | ||
/** | ||
* Return total quantity of objects currently in cache. Note, | ||
* that `stale` (see options) items are returned as part of this item count. | ||
*/ | ||
itemCount: number; | ||
length: number | ||
/** | ||
* Return total length of objects in cache taking into account `length` options function. | ||
*/ | ||
length: number; | ||
/** | ||
* Return an array of the keys in the cache. | ||
*/ | ||
keys(): any[]; | ||
/** | ||
* Return an array of the values in the cache. | ||
*/ | ||
values(): T[]; | ||
/** | ||
* Return an array of the cache entries ready for serialization and usage with `destinationCache.load(arr)`. | ||
*/ | ||
dump(): T[]; | ||
/** | ||
* Loads another cache entries array, obtained with `sourceCache.dump()`, | ||
* into the cache. The destination cache is reset before loading new entries | ||
* | ||
* @param cacheEntries Obtained from `sourceCache.dump()` | ||
*/ | ||
load(cacheEntries: T[]): void; | ||
} | ||
@@ -35,0 +150,0 @@ } |
{ | ||
"name": "@types/lru-cache", | ||
"version": "2.5.32", | ||
"description": "TypeScript definitions for lru-cache v2.5.0", | ||
"version": "4.0.0", | ||
"description": "TypeScript definitions for lru-cache", | ||
"license": "MIT", | ||
@@ -14,4 +14,5 @@ "author": "Bart van der Schoor <https://github.com/Bartvds>", | ||
"dependencies": {}, | ||
"typings": "index.d.ts", | ||
"typesPublisherContentHash": "1532ef8c5dac9ff760db2ea47fe868695ed450489d89d86f4abac49b14b57f30" | ||
"peerDependencies": {}, | ||
"typesPublisherContentHash": "5d4a5333b7a95dd946ab4e75939e286291894fd365b770b9090c6492dae802e0", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -5,15 +5,13 @@ # Installation | ||
# Summary | ||
This package contains type definitions for lru-cache v2.5.0 (https://github.com/isaacs/node-lru-cache). | ||
This package contains type definitions for lru-cache (https://github.com/isaacs/node-lru-cache). | ||
# Details | ||
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/lru-cache | ||
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/lru-cache | ||
Additional Details | ||
* Last updated: Mon, 19 Sep 2016 17:28:59 GMT | ||
* File structure: ProperModule | ||
* Library Dependencies: none | ||
* Module Dependencies: none | ||
* Global values: LRU | ||
* Last updated: Thu, 19 Jan 2017 14:46:19 GMT | ||
* Dependencies: none | ||
* Global values: none | ||
# Credits | ||
These definitions were written by Bart van der Schoor <https://github.com/Bartvds>. |
{ | ||
"authors": "Bart van der Schoor <https://github.com/Bartvds>", | ||
"definitionFilename": "index.d.ts", | ||
"libraryDependencies": [], | ||
"moduleDependencies": [], | ||
"libraryMajorVersion": "2", | ||
"libraryMinorVersion": "5", | ||
"libraryName": "lru-cache v2.5.0", | ||
"typingsPackageName": "lru-cache", | ||
"projectName": "https://github.com/isaacs/node-lru-cache", | ||
"name": "lru-cache", | ||
"libraryName": "lru-cache", | ||
"sourceRepoURL": "https://www.github.com/DefinitelyTyped/DefinitelyTyped", | ||
"sourceBranch": "types-2.0", | ||
"kind": "ProperModule", | ||
"globals": [ | ||
"LRU" | ||
], | ||
"declaredModules": [ | ||
"lru-cache" | ||
], | ||
"files": [ | ||
"index.d.ts" | ||
], | ||
"hasPackageJson": false, | ||
"contentHash": "1532ef8c5dac9ff760db2ea47fe868695ed450489d89d86f4abac49b14b57f30" | ||
"data": { | ||
"authors": "Bart van der Schoor <https://github.com/Bartvds>", | ||
"dependencies": {}, | ||
"pathMappings": {}, | ||
"libraryMajorVersion": 4, | ||
"libraryMinorVersion": 0, | ||
"typeScriptVersion": "2.0", | ||
"libraryName": "lru-cache", | ||
"typingsPackageName": "lru-cache", | ||
"projectName": "https://github.com/isaacs/node-lru-cache", | ||
"sourceRepoURL": "https://www.github.com/DefinitelyTyped/DefinitelyTyped", | ||
"globals": [], | ||
"declaredModules": [ | ||
"lru-cache/." | ||
], | ||
"files": [ | ||
"index.d.ts" | ||
], | ||
"hasPackageJson": false, | ||
"contentHash": "5d4a5333b7a95dd946ab4e75939e286291894fd365b770b9090c6492dae802e0" | ||
}, | ||
"isLatest": true | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7669
153
17