New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@peerbit/cache

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peerbit/cache - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

51

lib/esm/index.js

@@ -37,16 +37,18 @@ // Fifo

trim(time = +new Date()) {
const peek = this.list.head;
let outOfDate = peek &&
this.ttl !== undefined &&
this._map.get(peek.value).time < time - this.ttl;
while (outOfDate || this.currentSize > this.max) {
const key = this.list.shift();
if (key !== undefined) {
const cacheValue = this._map.get(key);
outOfDate = this.ttl !== undefined && cacheValue.time < time - this.ttl;
this._map.delete(key);
const wasDeleted = this.deleted.delete(key);
if (!wasDeleted) {
this.currentSize -= cacheValue.size;
for (;;) {
const headKey = this.list.head;
if (headKey?.value !== undefined) {
const cacheValue = this._map.get(headKey.value);
const outOfDate = this.ttl !== undefined && cacheValue.time < time - this.ttl;
if (outOfDate || this.currentSize > this.max) {
this.list.shift();
this._map.delete(headKey.value);
const wasDeleted = this.deleted.delete(headKey.value);
if (!wasDeleted) {
this.currentSize -= cacheValue.size;
}
}
else {
break;
}
}

@@ -58,25 +60,2 @@ else {

}
/*
trim(time = +new Date()) {
const peek = this.list.head;
let outOfDate =
peek &&
this.ttl !== undefined &&
this._map.get(peek.value)!.time < time - this.ttl;
while (outOfDate || this.currentSize > this.max) {
const key = this.list.shift();
if (key !== undefined) {
const cacheValue = this.del(key);
if (cacheValue) {
outOfDate = this.ttl !== undefined && cacheValue.time < time - this.ttl;
this._map.delete(key);
}
} else {
break;
}
}
}
*/
del(key) {

@@ -83,0 +62,0 @@ const cacheValue = this._map.get(key);

{
"name": "@peerbit/cache",
"version": "1.1.1",
"version": "2.0.0",
"description": "Simple cache",

@@ -37,3 +37,3 @@ "type": "module",

"devDependencies": {
"@peerbit/time": "1.0.4",
"@peerbit/time": "2.0.0",
"@types/yallist": "^4.0.1"

@@ -47,3 +47,3 @@ },

],
"gitHead": "6263a10a6236346d1c45d02dc0bf18eed1dc2995"
"gitHead": "c48cb37d237a25b0bcc849482b43f6941d53e3d5"
}

@@ -43,16 +43,17 @@ // Fifo

trim(time = +new Date()) {
const peek = this.list.head;
let outOfDate =
peek &&
this.ttl !== undefined &&
this._map.get(peek.value)!.time < time - this.ttl;
while (outOfDate || this.currentSize > this.max) {
const key = this.list.shift();
if (key !== undefined) {
const cacheValue = this._map.get(key)!;
outOfDate = this.ttl !== undefined && cacheValue.time < time - this.ttl;
this._map.delete(key);
const wasDeleted = this.deleted.delete(key);
if (!wasDeleted) {
this.currentSize -= cacheValue.size;
for (;;) {
const headKey = this.list.head;
if (headKey?.value !== undefined) {
const cacheValue = this._map.get(headKey.value)!;
const outOfDate =
this.ttl !== undefined && cacheValue.time < time - this.ttl;
if (outOfDate || this.currentSize > this.max) {
this.list.shift();
this._map.delete(headKey.value);
const wasDeleted = this.deleted.delete(headKey.value);
if (!wasDeleted) {
this.currentSize -= cacheValue.size;
}
} else {
break;
}

@@ -64,26 +65,3 @@ } else {

}
/*
trim(time = +new Date()) {
const peek = this.list.head;
let outOfDate =
peek &&
this.ttl !== undefined &&
this._map.get(peek.value)!.time < time - this.ttl;
while (outOfDate || this.currentSize > this.max) {
const key = this.list.shift();
if (key !== undefined) {
const cacheValue = this.del(key);
if (cacheValue) {
outOfDate = this.ttl !== undefined && cacheValue.time < time - this.ttl;
this._map.delete(key);
}
} else {
break;
}
}
}
*/
del(key: string) {

@@ -90,0 +68,0 @@ const cacheValue = this._map.get(key)!;

Sorry, the diff of this file is not supported yet

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