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

lru_map

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lru_map - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

4

lru.d.ts

@@ -42,3 +42,3 @@ // An entry holds the key and value, and pointers to any older and newer entries.

// Returns the removed entry or undefined if the cache was empty.
shift() : Entry<K,V> | undefined;
shift() : [K,V] | undefined;

@@ -59,3 +59,3 @@ // Get and register recent use of <key>.

// the cache object. You should look at the returned entry as being immutable.
find(key :K) : Entry<K,V> | undefined;
find(key :K) : V | undefined;

@@ -62,0 +62,0 @@ // Remove entry <key> from cache and return its value.

@@ -159,4 +159,4 @@ /**

--this.size;
return [entry.key, entry.value];
}
return entry;
};

@@ -169,3 +169,4 @@

LRUMap.prototype.find = function(key) {
return this._keymap.get(key);
let e = this._keymap.get(key);
return e ? e.value : undefined;
};

@@ -172,0 +173,0 @@

{
"name": "lru_map",
"version": "0.3.1",
"version": "0.3.2",
"description": "Finite key-value map using the Least Recently Used (LRU) algorithm where the most recently used objects are keept in the map while less recently used items are evicted to make room for new ones.",

@@ -5,0 +5,0 @@ "main": "lru.js",

@@ -77,8 +77,2 @@ # Least Recently Used (LRU) cache algorithm

```ts
// An entry holds the key and value, and pointers to any older and newer entries.
interface Entry<K,V> {
key :K;
value :V;
}
export class LRUMap<K,V> {

@@ -119,3 +113,3 @@ // Construct a new cache object which will hold up to limit entries.

// Returns the removed entry or undefined if the cache was empty.
shift() : Entry<K,V> | undefined;
shift() : [K,V] | undefined;

@@ -136,3 +130,3 @@ // Get and register recent use of <key>.

// the cache object. You should look at the returned entry as being immutable.
find(key :K) : Entry<K,V> | undefined;
find(key :K) : V | undefined;

@@ -153,6 +147,6 @@ // Remove entry <key> from cache and return its value.

// Returns an iterator over all entries, starting with the oldest.
entries() : Iterator<Entry<K,V>>;
entries() : Iterator<[K,V]>;
// Returns an iterator over all entries, starting with the oldest.
[Symbol.iterator]() : Iterator<Entry<K,V>>;
[Symbol.iterator]() : Iterator<[K,V]>;

@@ -168,2 +162,11 @@ // Call `fun` for each entry, starting with the oldest entry.

}
// An entry holds the key and value, and pointers to any older and newer entries.
// Entries might hold references to adjacent entries in the internal linked-list.
// Therefore you should never store or modify Entry objects. Instead, reference the
// key and value of an entry when needed.
interface Entry<K,V> {
key :K;
value :V;
}
```

@@ -170,0 +173,0 @@

@@ -168,12 +168,12 @@ // Test which will run in nodejs

let e = c2.shift();
asserteq(e.key, 'a');
asserteq(e.value, 1);
asserteq(e[0], 'a');
asserteq(e[1], 1);
e = c2.shift();
asserteq(e.key, 'b');
asserteq(e.value, 2);
asserteq(e[0], 'b');
asserteq(e[1], 2);
e = c2.shift();
asserteq(e.key, 'c');
asserteq(e.value, 3);
asserteq(e[0], 'c');
asserteq(e[1], 3);

@@ -180,0 +180,0 @@ // c2 should be empty

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