Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

lru-cache

Package Overview
Dependencies
1
Maintainers
2
Versions
134
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.2 to 3.2.0

32

lib/lru-cache.js

@@ -93,6 +93,24 @@ module.exports = LRUCache

LRUCache.prototype.rforEach = function (fn, thisp) {
thisp = thisp || this
this._lruList.forEach(function (hit) {
forEachStep(this, fn, hit, thisp)
}, this)
}
function forEachStep (self, fn, hit, thisp) {
if (isStale(self, hit)) {
del(self, hit)
if (!self._allowStale) {
hit = undefined
}
}
if (hit) {
fn.call(thisp, hit.value, hit.key, self)
}
}
LRUCache.prototype.forEach = function (fn, thisp) {
thisp = thisp || this
var i = 0
var itemCount = this._lruList.size

@@ -102,11 +120,3 @@ var keys = reverseKeys(this._lruList)

var hit = this._lruList.get(keys[k])
if (isStale(this, hit)) {
del(this, hit)
if (!this._allowStale) {
hit = undefined
}
}
if (hit) {
fn.call(thisp, hit.value, hit.key, this)
}
forEachStep(this, fn, hit, thisp)
}

@@ -113,0 +123,0 @@ }

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

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

@@ -99,2 +99,8 @@ # lru cache

* `rforEach(function(value,key,cache), [thisp])`
The same as `cache.forEach(...)` but items are iterated over in
reverse order. (ie, less recently used items are iterated over
first.)
* `keys()`

@@ -101,0 +107,0 @@

@@ -31,4 +31,14 @@ var test = require('tap').test

})
t.equal(i, order.length);
t.equal(i, order.length)
i = 0
order.reverse()
l.rforEach(function (val, key, cache) {
var j = order[i ++]
t.equal(cache, l)
t.equal(key, j)
t.equal(val, j.toString(2))
})
t.equal(i, order.length)
t.end()

@@ -35,0 +45,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