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

lru-object

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lru-object - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

dist/node.d.ts

6

dist/index.d.ts

@@ -1,1 +0,5 @@

export { default } from "./lru";
export default function createLRUCache<K, V>(capacity: number): {
[key: string]: V;
} | {
[key: number]: V;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = void 0;
var lru_1 = require("./lru");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return lru_1.default; } });
const lru_1 = require("./lru");
function createLRUCache(capacity) {
const lru = new lru_1.default(capacity);
const cache = lru.nodes;
const handler = {
get(_, prop) {
return lru.get(prop);
},
set(_, prop, value) {
lru.set(prop, value);
return true;
},
};
return new Proxy(cache, handler);
}
exports.default = createLRUCache;

15

dist/lru.d.ts

@@ -1,9 +0,3 @@

export declare class Node<K, V> {
key: any;
value: any;
prev: Node<K, V>;
next: Node<K, V>;
constructor(key?: any, value?: any, prev?: Node<K, V>, next?: Node<K, V>);
}
export declare class LRU<K, V> {
import Node from "./node";
export default class LRU<K, V> {
head: Node<K, V>;

@@ -25,6 +19,1 @@ tail: Node<K, V>;

}
export default function createLRUCache<K, V>(capacity: number): {
[key: string]: V;
} | {
[key: number]: V;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LRU = exports.Node = void 0;
class Node {
constructor(key, value, prev, next) {
this.key = key;
this.value = value;
this.prev = prev;
this.next = next;
}
}
exports.Node = Node;
const node_1 = require("./node");
class LRU {
constructor(capacity) {
this.head = new Node();
this.tail = new Node();
this.head = new node_1.default();
this.tail = new node_1.default();
this.head.next = this.tail;

@@ -22,5 +13,2 @@ this.tail.prev = this.head;

this.capacity = capacity;
if (capacity <= 0) {
console.error("LRU capacity must be gratter than 0");
}
}

@@ -43,3 +31,3 @@ peek(key) {

}
const newNode = new Node(key, value);
const newNode = new node_1.default(key, value);
const next = this.head.next;

@@ -86,17 +74,2 @@ this.head.next = newNode;

}
exports.LRU = LRU;
function createLRUCache(capacity) {
const lru = new LRU(capacity);
const cache = lru.nodes;
const handler = {
get: function (_, prop) {
return lru.get(prop);
},
set: function (_, prop, value) {
lru.set(prop, value);
return true;
},
};
return new Proxy(cache, handler);
}
exports.default = createLRUCache;
exports.default = LRU;
{
"name": "lru-object",
"version": "1.0.0",
"version": "1.0.1",
"description": "Javascript object with basic LRU functionalities",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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