Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lru-cache

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lru-cache - npm Package Compare versions

Comparing version 7.8.0 to 7.8.1

22

index.js

@@ -81,3 +81,6 @@ const perf = typeof performance === 'object' && performance &&

constructor (max) {
const UintArray = max ? getUintArray(max) : Array
if (max === 0) {
return []
}
const UintArray = getUintArray(max)
this.heap = new UintArray(max)

@@ -147,3 +150,2 @@ this.length = 0

this.keyMap = new Map()

@@ -305,3 +307,3 @@ this.keyList = new Array(max).fill(null)

while (this.calculatedSize > maxSize) {
this.evict()
this.evict(true)
}

@@ -526,4 +528,4 @@ this.calculatedSize += this.sizes[index]

}
if (this.size === this.max) {
return this.evict()
if (this.size === this.max && this.max !== 0) {
return this.evict(false)
}

@@ -540,3 +542,3 @@ if (this.free.length !== 0) {

const val = this.valList[this.head]
this.evict()
this.evict(true)
return val

@@ -546,3 +548,3 @@ }

evict () {
evict (free) {
const head = this.head

@@ -560,2 +562,8 @@ const k = this.keyList[head]

this.removeItemSize(head)
// if we aren't about to use the index, then null these out
if (free) {
this.keyList[head] = null
this.valList[head] = null
this.free.push(head)
}
this.head = this.next[head]

@@ -562,0 +570,0 @@ this.keyMap.delete(k)

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

@@ -26,2 +26,3 @@ "keywords": [

"clock-mock": "^1.0.4",
"heapdump": "^0.3.15",
"size-limit": "^7.0.8",

@@ -38,3 +39,6 @@ "tap": "^15.1.6"

"tap": {
"coverage-map": "map.js"
"coverage-map": "map.js",
"node-arg": [
"--expose-gc"
]
},

@@ -41,0 +45,0 @@ "size-limit": [

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

This is not primarily a TTL cache, and does not make strong TTL guarantees.
There is no preemptive pruning of expired items, but you _may_ set a TTL
on the cache or on a single `set`. If you do so, it will treat expired
items as missing, and delete them when fetched.
There is no preemptive pruning of expired items by default, but you _may_
set a TTL on the cache or on a single `set`. If you do so, it will treat
expired items as missing, and delete them when fetched. If you are more
interested in TTL caching than LRU caching, check out
[@isaacs/ttlcache](http://npm.im/@isaacs/ttlcache).

@@ -14,0 +16,0 @@ As of version 7, this is one of the most performant LRU implementations

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc