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.13.2 to 7.14.0

11

index.d.ts

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

public readonly maxSize: number
public readonly maxEntrySize: number
public readonly sizeCalculation:

@@ -324,2 +325,9 @@ | LRUCache.SizeCalculator<K, V>

type MaybeMaxEntrySizeLimit<K, V> =
| {
maxEntrySize: number
sizeCalculation?: SizeCalculator<K, V>
}
| {}
interface LimitedBySize<K, V> {

@@ -512,3 +520,4 @@ /**

DeprecatedOptions<K, V> &
SafetyBounds<K, V>
SafetyBounds<K, V> &
MaybeMaxEntrySizeLimit<K, V>

@@ -515,0 +524,0 @@ /**

25

index.js

@@ -160,2 +160,3 @@ const perf =

maxSize = 0,
maxEntrySize = 0,
sizeCalculation,

@@ -184,7 +185,8 @@ fetchMethod,

this.maxSize = maxSize
this.maxEntrySize = maxEntrySize || this.maxSize
this.sizeCalculation = sizeCalculation || length
if (this.sizeCalculation) {
if (!this.maxSize) {
if (!this.maxSize && !this.maxEntrySize) {
throw new TypeError(
'cannot set sizeCalculation without setting maxSize'
'cannot set sizeCalculation without setting maxSize or maxEntrySize'
)

@@ -236,6 +238,14 @@ }

if (this.maxSize !== 0) {
if (!isPosInt(this.maxSize)) {
// NB: maxEntrySize is set to maxSize if it's set
if (this.maxEntrySize !== 0) {
if (this.maxSize !== 0) {
if (!isPosInt(this.maxSize)) {
throw new TypeError(
'maxSize must be a positive integer if specified'
)
}
}
if (!isPosInt(this.maxEntrySize)) {
throw new TypeError(
'maxSize must be a positive integer if specified'
'maxEntrySize must be a positive integer if specified'
)

@@ -408,3 +418,3 @@ }

throw new TypeError(
'cannot set size without setting maxSize on cache'
'cannot set size without setting maxSize or maxEntrySize on cache'
)

@@ -581,3 +591,4 @@ }

// if the item doesn't fit, don't do anything
if (this.maxSize && size > this.maxSize) {
// NB: maxEntrySize set to maxSize by default
if (this.maxEntrySize && size > this.maxEntrySize) {
return this

@@ -584,0 +595,0 @@ }

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

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

@@ -121,5 +121,7 @@ # lru-cache

Optional, must be a positive integer if provided. Required if
other size tracking features are used.
Optional, must be a positive integer if provided.
Sets `maxItemSize` to the same value, unless a different value is
provided for `maxItemSize`.
At least one of `max`, `maxSize`, or `TTL` is required. This

@@ -132,2 +134,13 @@ must be a positive integer if set.

### `maxEntrySize`
Set to a positive integer to track the sizes of items added to
the cache, and prevent caching any item over a given size.
Attempting to add an item whose calculated size is greater than
this amount will be a no-op. The item will not be cached, and no
other items will be evicted.
Optional, must be a positive integer if provided. Defaults to
the value of `maxSize` if provided.
### `sizeCalculation`

@@ -134,0 +147,0 @@

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