evicting-cache 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +39 -2
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,2 +1,39 @@
1
- # evicting-cache
2
- LRU Cache Implementation
1
+ # Evicting Cache
2
+ JavaScript Cache using an LRU (Least Recently Used) algorithm
3
+
4
+ The cache is backed by a LinkedMap, which is a Map that maintains insertion order. When the cache is full, the least recently used item is evicted.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ // pnpm 🎉
10
+ pnpm add evicting-cache
11
+
12
+ // npm 🤷🏽‍♂️
13
+ npm install evicting-cache
14
+ ```
15
+
16
+ ## Usage
17
+ ```javascript
18
+ import EvictingCache from 'evicting-cache';
19
+
20
+ // Constructor accepts a number, which is the maximum number of items to store.
21
+ // default is 100
22
+ const cache = new EvictingCache(3);
23
+
24
+ // Obviously a contrived example, but this is what you get with AI...
25
+ cache.put('key1', 'value1');
26
+ cache.put('key2', 'value2');
27
+ cache.put('key3', 'value3');
28
+ cache.put('key4', 'value4');
29
+
30
+ console.log(cache.get('key1')); // undefined
31
+ console.log(cache.get('key2')); // value2
32
+ console.log(cache.get('key3')); // value3
33
+ console.log(cache.get('key4')); // value4
34
+
35
+ cache.put('key5', 'value5');
36
+
37
+ console.log(cache.get('key2')); // undefined
38
+
39
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "evicting-cache",
3
3
  "author": "D1g1talEntr0py",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "license": "ISC",
6
6
  "description": "Cache implementation with an LRU evicting policy",
7
7
  "type": "module",
@@ -15,11 +15,11 @@
15
15
  "@d1g1tal/collections": "^1.0.0"
16
16
  },
17
17
  "devDependencies": {
18
- "esbuild": "^0.19.9",
19
- "esbuild-library": "^1.0.5",
20
- "eslint": "^8.56.0",
18
+ "esbuild": "^0.20.1",
19
+ "esbuild-library": "^1.0.7",
20
+ "eslint": "^8.57.0",
21
21
  "eslint-plugin-compat": "^4.2.0",
22
- "eslint-plugin-jsdoc": "^46.9.1",
22
+ "eslint-plugin-jsdoc": "^48.2.0",
23
23
  "jest": "^29.7.0"
24
24
  },
25
25
  "browserslist": [