Socket
Socket
Sign inDemoInstall

lru

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lru - npm Package Compare versions

Comparing version 0.1.1 to 0.1.3

22

index.js

@@ -19,2 +19,5 @@ var LRU = exports.LRU = function (max) {

if (this.head) {
if (!(this.head in this.cache)) {
return this.reset();
}
this.cache[this.head].next = key;

@@ -41,5 +44,11 @@ }

if (element.next) {
if (!(element.next in this.cache)) {
return this.reset();
}
this.cache[element.next].prev = element.prev;
}
if (element.prev) {
if (!(element.prev in this.cache)) {
return this.reset();
}
this.cache[element.prev].next = element.next;

@@ -52,2 +61,5 @@ } else {

if (this.head) {
if (!(this.head in this.cache)) {
return this.reset();
}
this.cache[this.head].next = key;

@@ -62,2 +74,5 @@ }

delete this.cache[this.tail];
if (!(tail in this.cache)) {
return this.reset();
}
this.cache[tail].prev = null;

@@ -68,1 +83,8 @@ this.tail = tail;

LRU.prototype.reset = function () {
//Super shit but this sometimes (rarely) fails
this.cache = {};
this.length = 0;
this.head = this.tail = null;
};

2

package.json
{ "name" : "lru",
"description" : "A simple O(1) LRU cache",
"version" : "0.1.1",
"version" : "0.1.3",
"author" : "Chris O'Hara <cohara87@gmail.com>",

@@ -5,0 +5,0 @@ "main" : "index",

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