Socket
Socket
Sign inDemoInstall

lru-cache

Package Overview
Dependencies
0
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.16.1 to 7.16.2

107

index.d.ts

@@ -34,3 +34,18 @@ // Project: https://github.com/isaacs/node-lru-cache

//tslint:disable:member-access
/**
* Integer greater than 0, representing some number of milliseconds, or the
* time at which a TTL started counting from.
*/
declare type LRUMilliseconds = number
/**
* An integer greater than 0, reflecting the calculated size of items
*/
declare type LRUSize = number
/**
* An integer greater than 0, reflecting a number of items
*/
declare type LRUCount = number
declare class LRUCache<K, V> implements Iterable<[K, V]> {

@@ -45,7 +60,7 @@ constructor(options: LRUCache.Options<K, V>)

*/
public readonly length: number
public readonly length: LRUCount
public readonly max: number
public readonly maxSize: number
public readonly maxEntrySize: number
public readonly max: LRUCount
public readonly maxSize: LRUSize
public readonly maxEntrySize: LRUSize
public readonly sizeCalculation:

@@ -60,4 +75,4 @@ | LRUCache.SizeCalculator<K, V>

public readonly noDisposeOnSet: boolean
public readonly ttl: number
public readonly ttlResolution: number
public readonly ttl: LRUMilliseconds
public readonly ttlResolution: LRUMilliseconds
public readonly ttlAutopurge: boolean

@@ -78,3 +93,3 @@ public readonly allowStale: boolean

*/
public readonly size: number
public readonly size: LRUCount

@@ -84,3 +99,3 @@ /**

*/
public readonly calculatedSize: number
public readonly calculatedSize: LRUSize

@@ -177,3 +192,3 @@ /**

*/
public keys(): Generator<K>
public keys(): Generator<K, void, void>

@@ -186,3 +201,3 @@ /**

*/
public rkeys(): Generator<K>
public rkeys(): Generator<K, void, void>

@@ -193,3 +208,3 @@ /**

*/
public values(): Generator<V>
public values(): Generator<V, void, void>

@@ -202,3 +217,3 @@ /**

*/
public rvalues(): Generator<V>
public rvalues(): Generator<V, void, void>

@@ -209,3 +224,3 @@ /**

*/
public entries(): Generator<[K, V]>
public entries(): Generator<[K, V], void, void>

@@ -218,3 +233,3 @@ /**

*/
public rentries(): Generator<[K, V]>
public rentries(): Generator<[K, V], void, void>

@@ -225,3 +240,3 @@ /**

*/
public [Symbol.iterator](): Iterator<[K, V]>
public [Symbol.iterator](): Generator<[K, V], void, void>

@@ -281,10 +296,9 @@ /**

*/
public getRemainingTTL(key: K): number
public getRemainingTTL(key: K): LRUMilliseconds
}
declare namespace LRUCache {
type LRUMilliseconds = number
type DisposeReason = 'evict' | 'set' | 'delete'
type SizeCalculator<K, V> = (value: V, key: K) => number
type SizeCalculator<K, V> = (value: V, key: K) => LRUSize
type Disposer<K, V> = (

@@ -307,3 +321,3 @@ value: V,

*/
maxAge?: number
maxAge?: LRUMilliseconds

@@ -330,3 +344,3 @@ /**

*/
max: number
max: LRUCount
}

@@ -342,3 +356,3 @@

*/
maxEntrySize: number
maxEntrySize: LRUSize
sizeCalculation?: SizeCalculator<K, V>

@@ -356,6 +370,7 @@ }

* is added. Use with caution!
*
* Note also that size tracking can negatively impact performance,
* though for most cases, only minimally.
*/
maxSize: number
maxSize: LRUSize

@@ -368,5 +383,6 @@ /**

*
* Note that when `maxSize` or `maxEntrySize` are set, every item added
* MUST have a size specified, either via a `sizeCalculation` in the
* constructor, or `sizeCalculation` or `size` options to {@link set}.
* Note that when {@link maxSize} or {@link maxEntrySize} are set, every
* item added MUST have a size specified, either via a `sizeCalculation` in
* the constructor, or `sizeCalculation` or {@link size} options to
* {@link set}.
*/

@@ -389,3 +405,3 @@ sizeCalculation?: SizeCalculator<K, V>

*/
ttl: number
ttl: LRUMilliseconds

@@ -418,3 +434,3 @@ /**

*/
ttlResolution?: number
ttlResolution?: LRUMilliseconds

@@ -517,5 +533,4 @@ /**

*
* Note that the `fetchMethod` should ONLY return `undefined` in cases
* where either the abort controller has sent an abort signal, or the
* item should be removed from the cache.
* The `fetchMethod` should ONLY return `undefined` in cases where the
* abort controller has sent an abort signal.
*

@@ -573,7 +588,8 @@ * @since 7.6.0

*
* Note that when `maxSize` or `maxEntrySize` are set, every item added
* MUST have a size specified, either via a `sizeCalculation` in the
* constructor, or `sizeCalculation` or `size` options to {@link set}.
* Note that when {@link maxSize} or {@link maxEntrySize} are set, every
* item added MUST have a size specified, either via a `sizeCalculation` in
* the constructor, or {@link sizeCalculation} or `size` options to
* {@link set}.
*/
size?: number
size?: LRUSize
/**

@@ -584,9 +600,10 @@ * Overrides the {@link sizeCalculation} method set in the constructor.

*
* Note that when `maxSize` or `maxEntrySize` are set, every item added
* MUST have a size specified, either via a `sizeCalculation` in the
* constructor, or `sizeCalculation` or `size` options to {@link set}.
* Note that when {@link maxSize} or {@link maxEntrySize} are set, every
* item added MUST have a size specified, either via a `sizeCalculation` in
* the constructor, or `sizeCalculation` or {@link size} options to
* {@link set}.
*/
sizeCalculation?: SizeCalculator<K, V>
ttl?: number
start?: number
ttl?: LRUMilliseconds
start?: LRUMilliseconds
noDisposeOnSet?: boolean

@@ -634,5 +651,5 @@ noUpdateTTL?: boolean

noDeleteOnStaleGet?: boolean
size?: number
size?: LRUSize
sizeCalculation?: SizeCalculator<K, V>
ttl?: number
ttl?: LRUMilliseconds
noDisposeOnSet?: boolean

@@ -668,5 +685,5 @@ noUpdateTTL?: boolean

value: V
ttl?: number
size?: number
start?: number
ttl?: LRUMilliseconds
size?: LRUSize
start?: LRUMilliseconds
}

@@ -673,0 +690,0 @@ }

@@ -20,3 +20,4 @@ const perf =

}
abort() {
abort(reason = new Error('This operation was aborted')) {
this.signal.reason = reason
this.signal.dispatchEvent({

@@ -38,2 +39,3 @@ type: 'abort',

constructor() {
this.reason = undefined
this.aborted = false

@@ -374,5 +376,5 @@ this._listeners = []

}
updateItemAge(index) {}
setItemTTL(index, ttl, start) {}
isStale(index) {
updateItemAge(_index) {}
setItemTTL(_index, _ttl, _start) {}
isStale(_index) {
return false

@@ -426,5 +428,5 @@ }

}
removeItemSize(index) {}
addItemSize(index, size) {}
requireSize(k, v, size, sizeCalculation) {
removeItemSize(_index) {}
addItemSize(_index, _size) {}
requireSize(_k, _v, size, sizeCalculation) {
if (size || sizeCalculation) {

@@ -601,3 +603,3 @@ throw new TypeError(

dispose(v, k, reason) {}
dispose(_v, _k, _reason) {}

@@ -644,3 +646,3 @@ set(

if (this.isBackgroundFetch(oldVal)) {
oldVal.__abortController.abort()
oldVal.__abortController.abort(new Error('replaced'))
} else {

@@ -700,3 +702,3 @@ if (!noDisposeOnSet) {

if (this.isBackgroundFetch(v)) {
v.__abortController.abort()
v.__abortController.abort(new Error('evicted'))
} else {

@@ -758,4 +760,6 @@ this.dispose(v, k, 'evict')

this.set(k, v, fetchOpts.options)
return v
} else {
return eb(ac.signal.reason)
}
return v
}

@@ -784,3 +788,6 @@ const eb = er => {

}
const pcall = res => res(this.fetchMethod(k, v, fetchOpts))
const pcall = (res, rej) => {
ac.signal.addEventListener('abort', () => res())
this.fetchMethod(k, v, fetchOpts).then(res, rej)
}
const p = new Promise(pcall).then(cb, eb)

@@ -832,2 +839,3 @@ p.__abortController = ac

forceRefresh = false,
signal,
} = {}

@@ -854,2 +862,3 @@ ) {

allowStaleOnFetchRejection,
signal,
}

@@ -969,3 +978,3 @@

if (this.isBackgroundFetch(v)) {
v.__abortController.abort()
v.__abortController.abort(new Error('deleted'))
} else {

@@ -1005,3 +1014,3 @@ this.dispose(v, k, 'delete')

if (this.isBackgroundFetch(v)) {
v.__abortController.abort()
v.__abortController.abort(new Error('deleted'))
} else {

@@ -1008,0 +1017,0 @@ const k = this.keyList[index]

{
"name": "lru-cache",
"description": "A cache object that deletes the least-recently-used items.",
"version": "7.16.1",
"version": "7.16.2",
"author": "Isaac Z. Schlueter <i@izs.me>",

@@ -6,0 +6,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc