gitx.do 0.0.1 → 0.0.3
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.
- package/dist/cli/commands/blame.d.ts +259 -0
- package/dist/cli/commands/blame.d.ts.map +1 -0
- package/dist/cli/commands/blame.js +609 -0
- package/dist/cli/commands/blame.js.map +1 -0
- package/dist/cli/commands/branch.d.ts +249 -0
- package/dist/cli/commands/branch.d.ts.map +1 -0
- package/dist/cli/commands/branch.js +693 -0
- package/dist/cli/commands/branch.js.map +1 -0
- package/dist/cli/commands/commit.d.ts +182 -0
- package/dist/cli/commands/commit.d.ts.map +1 -0
- package/dist/cli/commands/commit.js +437 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/diff.d.ts +464 -0
- package/dist/cli/commands/diff.d.ts.map +1 -0
- package/dist/cli/commands/diff.js +958 -0
- package/dist/cli/commands/diff.js.map +1 -0
- package/dist/cli/commands/log.d.ts +239 -0
- package/dist/cli/commands/log.d.ts.map +1 -0
- package/dist/cli/commands/log.js +535 -0
- package/dist/cli/commands/log.js.map +1 -0
- package/dist/cli/commands/review.d.ts +457 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +533 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/status.d.ts +269 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +493 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/web.d.ts +199 -0
- package/dist/cli/commands/web.d.ts.map +1 -0
- package/dist/cli/commands/web.js +696 -0
- package/dist/cli/commands/web.js.map +1 -0
- package/dist/cli/fs-adapter.d.ts +656 -0
- package/dist/cli/fs-adapter.d.ts.map +1 -0
- package/dist/cli/fs-adapter.js +1179 -0
- package/dist/cli/fs-adapter.js.map +1 -0
- package/dist/cli/index.d.ts +387 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +523 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/ui/components/DiffView.d.ts +7 -0
- package/dist/cli/ui/components/DiffView.d.ts.map +1 -0
- package/dist/cli/ui/components/DiffView.js +11 -0
- package/dist/cli/ui/components/DiffView.js.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts +6 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.js +11 -0
- package/dist/cli/ui/components/ErrorDisplay.js.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts +9 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.js +12 -0
- package/dist/cli/ui/components/FuzzySearch.js.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts +6 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.js +10 -0
- package/dist/cli/ui/components/LoadingSpinner.js.map +1 -0
- package/dist/cli/ui/components/NavigationList.d.ts +9 -0
- package/dist/cli/ui/components/NavigationList.d.ts.map +1 -0
- package/dist/cli/ui/components/NavigationList.js +11 -0
- package/dist/cli/ui/components/NavigationList.js.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts +8 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.js +11 -0
- package/dist/cli/ui/components/ScrollableContent.js.map +1 -0
- package/dist/cli/ui/components/index.d.ts +7 -0
- package/dist/cli/ui/components/index.d.ts.map +1 -0
- package/dist/cli/ui/components/index.js +9 -0
- package/dist/cli/ui/components/index.js.map +1 -0
- package/dist/cli/ui/terminal-ui.d.ts +52 -0
- package/dist/cli/ui/terminal-ui.d.ts.map +1 -0
- package/dist/cli/ui/terminal-ui.js +121 -0
- package/dist/cli/ui/terminal-ui.js.map +1 -0
- package/dist/durable-object/object-store.d.ts +401 -23
- package/dist/durable-object/object-store.d.ts.map +1 -1
- package/dist/durable-object/object-store.js +414 -25
- package/dist/durable-object/object-store.js.map +1 -1
- package/dist/durable-object/schema.d.ts +188 -0
- package/dist/durable-object/schema.d.ts.map +1 -1
- package/dist/durable-object/schema.js +160 -0
- package/dist/durable-object/schema.js.map +1 -1
- package/dist/durable-object/wal.d.ts +336 -31
- package/dist/durable-object/wal.d.ts.map +1 -1
- package/dist/durable-object/wal.js +272 -27
- package/dist/durable-object/wal.js.map +1 -1
- package/dist/index.d.ts +379 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +379 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp/adapter.d.ts +579 -38
- package/dist/mcp/adapter.d.ts.map +1 -1
- package/dist/mcp/adapter.js +426 -33
- package/dist/mcp/adapter.js.map +1 -1
- package/dist/mcp/sandbox.d.ts +532 -29
- package/dist/mcp/sandbox.d.ts.map +1 -1
- package/dist/mcp/sandbox.js +389 -22
- package/dist/mcp/sandbox.js.map +1 -1
- package/dist/mcp/sdk-adapter.d.ts +478 -56
- package/dist/mcp/sdk-adapter.d.ts.map +1 -1
- package/dist/mcp/sdk-adapter.js +346 -44
- package/dist/mcp/sdk-adapter.js.map +1 -1
- package/dist/mcp/tools.d.ts +445 -30
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +363 -33
- package/dist/mcp/tools.js.map +1 -1
- package/dist/ops/blame.d.ts +424 -21
- package/dist/ops/blame.d.ts.map +1 -1
- package/dist/ops/blame.js +303 -20
- package/dist/ops/blame.js.map +1 -1
- package/dist/ops/branch.d.ts +583 -32
- package/dist/ops/branch.d.ts.map +1 -1
- package/dist/ops/branch.js +365 -23
- package/dist/ops/branch.js.map +1 -1
- package/dist/ops/commit-traversal.d.ts +164 -24
- package/dist/ops/commit-traversal.d.ts.map +1 -1
- package/dist/ops/commit-traversal.js +68 -2
- package/dist/ops/commit-traversal.js.map +1 -1
- package/dist/ops/commit.d.ts +387 -53
- package/dist/ops/commit.d.ts.map +1 -1
- package/dist/ops/commit.js +249 -29
- package/dist/ops/commit.js.map +1 -1
- package/dist/ops/merge-base.d.ts +195 -21
- package/dist/ops/merge-base.d.ts.map +1 -1
- package/dist/ops/merge-base.js +122 -12
- package/dist/ops/merge-base.js.map +1 -1
- package/dist/ops/merge.d.ts +600 -130
- package/dist/ops/merge.d.ts.map +1 -1
- package/dist/ops/merge.js +408 -60
- package/dist/ops/merge.js.map +1 -1
- package/dist/ops/tag.d.ts +67 -2
- package/dist/ops/tag.d.ts.map +1 -1
- package/dist/ops/tag.js +42 -1
- package/dist/ops/tag.js.map +1 -1
- package/dist/ops/tree-builder.d.ts +102 -6
- package/dist/ops/tree-builder.d.ts.map +1 -1
- package/dist/ops/tree-builder.js +30 -5
- package/dist/ops/tree-builder.js.map +1 -1
- package/dist/ops/tree-diff.d.ts +50 -2
- package/dist/ops/tree-diff.d.ts.map +1 -1
- package/dist/ops/tree-diff.js +50 -2
- package/dist/ops/tree-diff.js.map +1 -1
- package/dist/pack/delta.d.ts +211 -39
- package/dist/pack/delta.d.ts.map +1 -1
- package/dist/pack/delta.js +232 -46
- package/dist/pack/delta.js.map +1 -1
- package/dist/pack/format.d.ts +390 -28
- package/dist/pack/format.d.ts.map +1 -1
- package/dist/pack/format.js +344 -33
- package/dist/pack/format.js.map +1 -1
- package/dist/pack/full-generation.d.ts +313 -28
- package/dist/pack/full-generation.d.ts.map +1 -1
- package/dist/pack/full-generation.js +238 -19
- package/dist/pack/full-generation.js.map +1 -1
- package/dist/pack/generation.d.ts +346 -23
- package/dist/pack/generation.d.ts.map +1 -1
- package/dist/pack/generation.js +269 -21
- package/dist/pack/generation.js.map +1 -1
- package/dist/pack/index.d.ts +407 -86
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +351 -70
- package/dist/pack/index.js.map +1 -1
- package/dist/refs/branch.d.ts +517 -71
- package/dist/refs/branch.d.ts.map +1 -1
- package/dist/refs/branch.js +410 -26
- package/dist/refs/branch.js.map +1 -1
- package/dist/refs/storage.d.ts +610 -57
- package/dist/refs/storage.d.ts.map +1 -1
- package/dist/refs/storage.js +481 -29
- package/dist/refs/storage.js.map +1 -1
- package/dist/refs/tag.d.ts +677 -67
- package/dist/refs/tag.d.ts.map +1 -1
- package/dist/refs/tag.js +497 -30
- package/dist/refs/tag.js.map +1 -1
- package/dist/storage/lru-cache.d.ts +556 -53
- package/dist/storage/lru-cache.d.ts.map +1 -1
- package/dist/storage/lru-cache.js +439 -36
- package/dist/storage/lru-cache.js.map +1 -1
- package/dist/storage/object-index.d.ts +483 -38
- package/dist/storage/object-index.d.ts.map +1 -1
- package/dist/storage/object-index.js +388 -22
- package/dist/storage/object-index.js.map +1 -1
- package/dist/storage/r2-pack.d.ts +957 -94
- package/dist/storage/r2-pack.d.ts.map +1 -1
- package/dist/storage/r2-pack.js +756 -48
- package/dist/storage/r2-pack.js.map +1 -1
- package/dist/tiered/cdc-pipeline.d.ts +1610 -38
- package/dist/tiered/cdc-pipeline.d.ts.map +1 -1
- package/dist/tiered/cdc-pipeline.js +1131 -22
- package/dist/tiered/cdc-pipeline.js.map +1 -1
- package/dist/tiered/migration.d.ts +903 -41
- package/dist/tiered/migration.d.ts.map +1 -1
- package/dist/tiered/migration.js +646 -24
- package/dist/tiered/migration.js.map +1 -1
- package/dist/tiered/parquet-writer.d.ts +944 -47
- package/dist/tiered/parquet-writer.d.ts.map +1 -1
- package/dist/tiered/parquet-writer.js +667 -39
- package/dist/tiered/parquet-writer.js.map +1 -1
- package/dist/tiered/read-path.d.ts +728 -34
- package/dist/tiered/read-path.d.ts.map +1 -1
- package/dist/tiered/read-path.js +310 -27
- package/dist/tiered/read-path.js.map +1 -1
- package/dist/types/objects.d.ts +457 -0
- package/dist/types/objects.d.ts.map +1 -1
- package/dist/types/objects.js +305 -4
- package/dist/types/objects.js.map +1 -1
- package/dist/types/storage.d.ts +407 -35
- package/dist/types/storage.d.ts.map +1 -1
- package/dist/types/storage.js +27 -3
- package/dist/types/storage.js.map +1 -1
- package/dist/utils/hash.d.ts +133 -12
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +133 -12
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/sha1.d.ts +102 -9
- package/dist/utils/sha1.d.ts.map +1 -1
- package/dist/utils/sha1.js +114 -11
- package/dist/utils/sha1.js.map +1 -1
- package/dist/wire/capabilities.d.ts +896 -88
- package/dist/wire/capabilities.d.ts.map +1 -1
- package/dist/wire/capabilities.js +566 -62
- package/dist/wire/capabilities.js.map +1 -1
- package/dist/wire/pkt-line.d.ts +293 -15
- package/dist/wire/pkt-line.d.ts.map +1 -1
- package/dist/wire/pkt-line.js +251 -15
- package/dist/wire/pkt-line.js.map +1 -1
- package/dist/wire/receive-pack.d.ts +814 -64
- package/dist/wire/receive-pack.d.ts.map +1 -1
- package/dist/wire/receive-pack.js +542 -41
- package/dist/wire/receive-pack.js.map +1 -1
- package/dist/wire/smart-http.d.ts +575 -97
- package/dist/wire/smart-http.d.ts.map +1 -1
- package/dist/wire/smart-http.js +337 -46
- package/dist/wire/smart-http.js.map +1 -1
- package/dist/wire/upload-pack.d.ts +492 -98
- package/dist/wire/upload-pack.d.ts.map +1 -1
- package/dist/wire/upload-pack.js +347 -59
- package/dist/wire/upload-pack.js.map +1 -1
- package/package.json +10 -2
|
@@ -1,64 +1,261 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LRU Cache
|
|
3
|
-
*
|
|
2
|
+
* @fileoverview LRU Cache Implementation for Hot Objects
|
|
3
|
+
*
|
|
4
|
+
* This module provides a high-performance Least Recently Used (LRU) cache
|
|
5
|
+
* implementation optimized for storing frequently accessed Git objects.
|
|
6
|
+
*
|
|
7
|
+
* ## Features
|
|
8
|
+
*
|
|
9
|
+
* - **Dual Limits**: Supports both count-based and byte-size-based limits
|
|
10
|
+
* - **TTL Support**: Optional time-to-live for automatic entry expiration
|
|
11
|
+
* - **Eviction Callbacks**: Hook into eviction events for cleanup or analytics
|
|
12
|
+
* - **Statistics Tracking**: Built-in hit/miss tracking and hit rate calculation
|
|
13
|
+
* - **O(1) Operations**: All get/set/delete operations are O(1) using a doubly linked list
|
|
14
|
+
*
|
|
15
|
+
* ## Implementation Details
|
|
16
|
+
*
|
|
17
|
+
* The cache uses a combination of:
|
|
18
|
+
* - A Map for O(1) key lookup
|
|
19
|
+
* - A doubly linked list for O(1) LRU ordering
|
|
20
|
+
*
|
|
21
|
+
* When the cache exceeds its limits, the least recently used items are evicted.
|
|
22
|
+
* Items can also be evicted due to TTL expiration.
|
|
23
|
+
*
|
|
24
|
+
* @module storage/lru-cache
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Create a cache with 100 items max and 10MB size limit
|
|
29
|
+
* const cache = new LRUCache<string, Uint8Array>({
|
|
30
|
+
* maxCount: 100,
|
|
31
|
+
* maxBytes: 10 * 1024 * 1024,
|
|
32
|
+
* defaultTTL: 3600000, // 1 hour
|
|
33
|
+
* onEvict: (key, value, reason) => {
|
|
34
|
+
* console.log(`Evicted ${key}: ${reason}`);
|
|
35
|
+
* }
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // Store and retrieve values
|
|
39
|
+
* cache.set('object-sha', objectData);
|
|
40
|
+
* const data = cache.get('object-sha');
|
|
41
|
+
*
|
|
42
|
+
* // Check statistics
|
|
43
|
+
* const stats = cache.getStats();
|
|
44
|
+
* console.log(`Hit rate: ${stats.hitRate}%`);
|
|
45
|
+
* ```
|
|
4
46
|
*/
|
|
5
47
|
/**
|
|
6
|
-
* Configuration options for the LRU cache
|
|
48
|
+
* Configuration options for the LRU cache.
|
|
49
|
+
*
|
|
50
|
+
* @description
|
|
51
|
+
* Defines the behavior and limits of the cache. All options are optional
|
|
52
|
+
* and have sensible defaults (unlimited count/size, no TTL).
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const options: CacheOptions = {
|
|
57
|
+
* maxCount: 1000,
|
|
58
|
+
* maxBytes: 50 * 1024 * 1024, // 50MB
|
|
59
|
+
* defaultTTL: 3600000, // 1 hour
|
|
60
|
+
* sizeCalculator: (value) => value.byteLength,
|
|
61
|
+
* onEvict: (key, value, reason) => {
|
|
62
|
+
* console.log(`Evicted: ${key} (${reason})`);
|
|
63
|
+
* }
|
|
64
|
+
* };
|
|
65
|
+
* ```
|
|
7
66
|
*/
|
|
8
67
|
export interface CacheOptions {
|
|
9
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Maximum number of items in the cache.
|
|
70
|
+
* When exceeded, least recently used items are evicted.
|
|
71
|
+
* @default Infinity
|
|
72
|
+
*/
|
|
10
73
|
maxCount?: number;
|
|
11
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Maximum size in bytes for the cache.
|
|
76
|
+
* When exceeded, least recently used items are evicted.
|
|
77
|
+
* @default Infinity
|
|
78
|
+
*/
|
|
12
79
|
maxBytes?: number;
|
|
13
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Default TTL in milliseconds for cache entries.
|
|
82
|
+
* Entries expire after this duration unless overridden per-entry.
|
|
83
|
+
* @default undefined (no expiration)
|
|
84
|
+
*/
|
|
14
85
|
defaultTTL?: number;
|
|
15
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Function to calculate size of a value in bytes.
|
|
88
|
+
* Used when no explicit size is provided in set().
|
|
89
|
+
* @default defaultSizeCalculator
|
|
90
|
+
*/
|
|
16
91
|
sizeCalculator?: <T>(value: T) => number;
|
|
17
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Callback when an item is evicted from the cache.
|
|
94
|
+
* Useful for cleanup, logging, or analytics.
|
|
95
|
+
*/
|
|
18
96
|
onEvict?: <K, V>(key: K, value: V, reason: EvictionReason) => void;
|
|
19
97
|
}
|
|
20
98
|
/**
|
|
21
|
-
* Reason why an item was evicted from the cache
|
|
99
|
+
* Reason why an item was evicted from the cache.
|
|
100
|
+
*
|
|
101
|
+
* @description
|
|
102
|
+
* Indicates the cause of eviction, useful for understanding cache behavior:
|
|
103
|
+
* - `lru`: Evicted to make room for new items (least recently used)
|
|
104
|
+
* - `ttl`: Expired based on time-to-live
|
|
105
|
+
* - `size`: Evicted because cache exceeded byte limit
|
|
106
|
+
* - `manual`: Explicitly deleted via delete() method
|
|
107
|
+
* - `clear`: Removed during clear() operation
|
|
22
108
|
*/
|
|
23
109
|
export type EvictionReason = 'lru' | 'ttl' | 'size' | 'manual' | 'clear';
|
|
24
110
|
/**
|
|
25
|
-
* Statistics about cache performance
|
|
111
|
+
* Statistics about cache performance.
|
|
112
|
+
*
|
|
113
|
+
* @description
|
|
114
|
+
* Provides metrics for monitoring cache effectiveness and capacity.
|
|
115
|
+
* Use these stats to tune cache size and identify performance issues.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const stats = cache.getStats();
|
|
120
|
+
* console.log(`Hit rate: ${stats.hitRate}%`);
|
|
121
|
+
* console.log(`Cache utilization: ${stats.count}/${maxCount} items`);
|
|
122
|
+
* console.log(`Memory usage: ${(stats.bytes / 1024 / 1024).toFixed(2)} MB`);
|
|
123
|
+
* ```
|
|
26
124
|
*/
|
|
27
125
|
export interface CacheStats {
|
|
28
|
-
/** Number of cache hits */
|
|
126
|
+
/** Number of cache hits (successful gets) */
|
|
29
127
|
hits: number;
|
|
30
|
-
/** Number of cache misses */
|
|
128
|
+
/** Number of cache misses (get returned undefined) */
|
|
31
129
|
misses: number;
|
|
32
130
|
/** Current number of items in the cache */
|
|
33
131
|
count: number;
|
|
34
|
-
/** Current size in bytes */
|
|
132
|
+
/** Current size in bytes of all cached items */
|
|
35
133
|
bytes: number;
|
|
36
|
-
/**
|
|
134
|
+
/** Total number of evictions since creation/last reset */
|
|
37
135
|
evictions: number;
|
|
38
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* Hit rate as a percentage (0-100).
|
|
138
|
+
* Calculated as hits / (hits + misses) * 100.
|
|
139
|
+
*/
|
|
39
140
|
hitRate: number;
|
|
40
141
|
}
|
|
41
142
|
/**
|
|
42
|
-
* Entry stored in the cache
|
|
143
|
+
* Entry stored in the cache.
|
|
144
|
+
*
|
|
145
|
+
* @description
|
|
146
|
+
* Internal representation of a cached item with metadata for
|
|
147
|
+
* LRU tracking, TTL expiration, and size accounting.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const entry: CacheEntry<Buffer> = {
|
|
152
|
+
* value: Buffer.from('data'),
|
|
153
|
+
* size: 4,
|
|
154
|
+
* createdAt: Date.now(),
|
|
155
|
+
* expiresAt: Date.now() + 3600000,
|
|
156
|
+
* lastAccessed: Date.now()
|
|
157
|
+
* };
|
|
158
|
+
* ```
|
|
43
159
|
*/
|
|
44
160
|
export interface CacheEntry<V> {
|
|
161
|
+
/** The cached value */
|
|
45
162
|
value: V;
|
|
163
|
+
/** Size of this entry in bytes */
|
|
46
164
|
size: number;
|
|
165
|
+
/** Timestamp when the entry was created */
|
|
47
166
|
createdAt: number;
|
|
167
|
+
/**
|
|
168
|
+
* Timestamp when the entry expires, or null if no expiration.
|
|
169
|
+
* Entry will return undefined from get() after this time.
|
|
170
|
+
*/
|
|
48
171
|
expiresAt: number | null;
|
|
172
|
+
/** Timestamp when the entry was last accessed (for LRU ordering) */
|
|
49
173
|
lastAccessed: number;
|
|
50
174
|
}
|
|
51
175
|
/**
|
|
52
|
-
* Options for setting a cache entry
|
|
176
|
+
* Options for setting a cache entry.
|
|
177
|
+
*
|
|
178
|
+
* @description
|
|
179
|
+
* Allows per-entry configuration of TTL and explicit size specification.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* // Set with custom TTL
|
|
184
|
+
* cache.set('key', value, { ttl: 60000 }); // 1 minute TTL
|
|
185
|
+
*
|
|
186
|
+
* // Set with explicit size (useful when sizeCalculator is expensive)
|
|
187
|
+
* cache.set('key', largeObject, { size: knownSize });
|
|
188
|
+
* ```
|
|
53
189
|
*/
|
|
54
190
|
export interface SetOptions {
|
|
55
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* TTL in milliseconds for this specific entry.
|
|
193
|
+
* Overrides the cache's defaultTTL.
|
|
194
|
+
*/
|
|
56
195
|
ttl?: number;
|
|
57
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* Size in bytes for this entry.
|
|
198
|
+
* Overrides the sizeCalculator result.
|
|
199
|
+
*/
|
|
58
200
|
size?: number;
|
|
59
201
|
}
|
|
60
202
|
/**
|
|
61
|
-
* LRU Cache class for storing hot objects with size and count limits
|
|
203
|
+
* LRU Cache class for storing hot objects with size and count limits.
|
|
204
|
+
*
|
|
205
|
+
* @description
|
|
206
|
+
* A high-performance Least Recently Used cache with the following features:
|
|
207
|
+
*
|
|
208
|
+
* - **O(1) Operations**: Get, set, and delete are all constant time
|
|
209
|
+
* - **Dual Limits**: Supports both count and byte-size limits
|
|
210
|
+
* - **TTL Support**: Optional per-entry or default time-to-live
|
|
211
|
+
* - **Eviction Events**: Callbacks when items are removed
|
|
212
|
+
* - **Statistics**: Track hits, misses, and evictions
|
|
213
|
+
*
|
|
214
|
+
* The cache maintains items in order of recent use. When the cache is full,
|
|
215
|
+
* the least recently used items are evicted first.
|
|
216
|
+
*
|
|
217
|
+
* ## Type Parameters
|
|
218
|
+
*
|
|
219
|
+
* - `K`: The type of cache keys (default: string)
|
|
220
|
+
* - `V`: The type of cached values (default: unknown)
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* // Basic usage with string keys and Uint8Array values
|
|
225
|
+
* const objectCache = new LRUCache<string, Uint8Array>({
|
|
226
|
+
* maxCount: 1000,
|
|
227
|
+
* maxBytes: 100 * 1024 * 1024 // 100MB
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* // Store a value
|
|
231
|
+
* objectCache.set(sha, objectData);
|
|
232
|
+
*
|
|
233
|
+
* // Retrieve a value (returns undefined if not found or expired)
|
|
234
|
+
* const data = objectCache.get(sha);
|
|
235
|
+
*
|
|
236
|
+
* // Check without affecting LRU order
|
|
237
|
+
* if (objectCache.has(sha)) {
|
|
238
|
+
* const peeked = objectCache.peek(sha);
|
|
239
|
+
* }
|
|
240
|
+
*
|
|
241
|
+
* // Remove expired entries
|
|
242
|
+
* const pruned = objectCache.prune();
|
|
243
|
+
* console.log(`Removed ${pruned} expired entries`);
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* // With eviction callback for cleanup
|
|
249
|
+
* const cache = new LRUCache<string, Resource>({
|
|
250
|
+
* maxCount: 100,
|
|
251
|
+
* onEvict: (key, value, reason) => {
|
|
252
|
+
* if (reason !== 'clear') {
|
|
253
|
+
* value.dispose(); // Clean up resources
|
|
254
|
+
* }
|
|
255
|
+
* console.log(`Evicted ${key}: ${reason}`);
|
|
256
|
+
* }
|
|
257
|
+
* });
|
|
258
|
+
* ```
|
|
62
259
|
*/
|
|
63
260
|
export declare class LRUCache<K = string, V = unknown> {
|
|
64
261
|
private cache;
|
|
@@ -74,115 +271,421 @@ export declare class LRUCache<K = string, V = unknown> {
|
|
|
74
271
|
private sizeCalculator;
|
|
75
272
|
private onEvict?;
|
|
76
273
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
274
|
+
* Creates a new LRU cache instance.
|
|
275
|
+
*
|
|
276
|
+
* @description
|
|
277
|
+
* Initializes the cache with the specified options. All options have
|
|
278
|
+
* sensible defaults for unlimited caching.
|
|
279
|
+
*
|
|
280
|
+
* @param options - Configuration options for the cache
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* // Simple cache with count limit
|
|
285
|
+
* const cache = new LRUCache({ maxCount: 100 });
|
|
286
|
+
*
|
|
287
|
+
* // Cache with size limit and TTL
|
|
288
|
+
* const cache = new LRUCache({
|
|
289
|
+
* maxBytes: 50 * 1024 * 1024, // 50MB
|
|
290
|
+
* defaultTTL: 3600000 // 1 hour
|
|
291
|
+
* });
|
|
292
|
+
*
|
|
293
|
+
* // Cache with custom size calculator for Uint8Array
|
|
294
|
+
* const binaryCache = new LRUCache<string, Uint8Array>({
|
|
295
|
+
* maxBytes: 100 * 1024 * 1024,
|
|
296
|
+
* sizeCalculator: (arr) => arr.byteLength
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
79
299
|
*/
|
|
80
300
|
constructor(options?: CacheOptions);
|
|
81
301
|
/**
|
|
82
|
-
*
|
|
302
|
+
* Checks if an entry is expired.
|
|
303
|
+
*
|
|
304
|
+
* @param entry - The cache entry to check
|
|
305
|
+
* @returns true if the entry has expired
|
|
306
|
+
*
|
|
307
|
+
* @internal
|
|
83
308
|
*/
|
|
84
309
|
private isExpired;
|
|
85
310
|
/**
|
|
86
|
-
*
|
|
311
|
+
* Moves a node to the head (most recently used position).
|
|
312
|
+
*
|
|
313
|
+
* @param node - The node to move
|
|
314
|
+
*
|
|
315
|
+
* @internal
|
|
87
316
|
*/
|
|
88
317
|
private moveToHead;
|
|
89
318
|
/**
|
|
90
|
-
*
|
|
319
|
+
* Removes a node from the linked list.
|
|
320
|
+
*
|
|
321
|
+
* @param node - The node to remove
|
|
322
|
+
*
|
|
323
|
+
* @internal
|
|
91
324
|
*/
|
|
92
325
|
private removeNode;
|
|
93
326
|
/**
|
|
94
|
-
*
|
|
327
|
+
* Adds a node to the head of the list.
|
|
328
|
+
*
|
|
329
|
+
* @param node - The node to add
|
|
330
|
+
*
|
|
331
|
+
* @internal
|
|
95
332
|
*/
|
|
96
333
|
private addToHead;
|
|
97
334
|
/**
|
|
98
|
-
*
|
|
335
|
+
* Evicts items until the cache can accommodate a new item.
|
|
336
|
+
*
|
|
337
|
+
* @param requiredSize - Size in bytes needed for the new item
|
|
338
|
+
*
|
|
339
|
+
* @internal
|
|
99
340
|
*/
|
|
100
341
|
private evictToFit;
|
|
101
342
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
343
|
+
* Gets a value from the cache.
|
|
344
|
+
*
|
|
345
|
+
* @description
|
|
346
|
+
* Retrieves a value by key. If the key exists and hasn't expired,
|
|
347
|
+
* returns the value and moves the entry to the most recently used position.
|
|
348
|
+
* If the key doesn't exist or has expired, returns undefined.
|
|
349
|
+
*
|
|
350
|
+
* @param key - The cache key to look up
|
|
351
|
+
*
|
|
104
352
|
* @returns The cached value or undefined if not found/expired
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```typescript
|
|
356
|
+
* const cache = new LRUCache<string, string>();
|
|
357
|
+
* cache.set('greeting', 'hello');
|
|
358
|
+
*
|
|
359
|
+
* const value = cache.get('greeting'); // 'hello'
|
|
360
|
+
* const missing = cache.get('nonexistent'); // undefined
|
|
361
|
+
* ```
|
|
105
362
|
*/
|
|
106
363
|
get(key: K): V | undefined;
|
|
107
364
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @
|
|
111
|
-
*
|
|
112
|
-
*
|
|
365
|
+
* Sets a value in the cache.
|
|
366
|
+
*
|
|
367
|
+
* @description
|
|
368
|
+
* Stores a value with the given key. If the key already exists,
|
|
369
|
+
* updates the value. If storing the value would exceed limits,
|
|
370
|
+
* evicts least recently used items first.
|
|
371
|
+
*
|
|
372
|
+
* Returns false if the value is larger than maxBytes (cannot fit).
|
|
373
|
+
*
|
|
374
|
+
* @param key - The cache key
|
|
375
|
+
* @param value - The value to cache
|
|
376
|
+
* @param options - Optional per-entry settings (TTL, size)
|
|
377
|
+
*
|
|
378
|
+
* @returns true if successfully stored, false if value too large
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const cache = new LRUCache<string, Uint8Array>({
|
|
383
|
+
* maxBytes: 1024
|
|
384
|
+
* });
|
|
385
|
+
*
|
|
386
|
+
* // Basic set
|
|
387
|
+
* cache.set('key1', new Uint8Array([1, 2, 3]));
|
|
388
|
+
*
|
|
389
|
+
* // Set with custom TTL
|
|
390
|
+
* cache.set('key2', data, { ttl: 60000 }); // 1 minute
|
|
391
|
+
*
|
|
392
|
+
* // Set with explicit size
|
|
393
|
+
* cache.set('key3', complexObject, { size: 1000 });
|
|
394
|
+
*
|
|
395
|
+
* // Returns false if value too large
|
|
396
|
+
* const hugeData = new Uint8Array(10000);
|
|
397
|
+
* cache.set('huge', hugeData); // returns false
|
|
398
|
+
* ```
|
|
113
399
|
*/
|
|
114
400
|
set(key: K, value: V, options?: SetOptions): boolean;
|
|
115
401
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
402
|
+
* Checks if a key exists in the cache.
|
|
403
|
+
*
|
|
404
|
+
* @description
|
|
405
|
+
* Returns true if the key exists and hasn't expired.
|
|
406
|
+
* Does NOT update LRU order (use peek() for that too).
|
|
407
|
+
*
|
|
408
|
+
* @param key - The cache key to check
|
|
409
|
+
*
|
|
118
410
|
* @returns true if the key exists and is not expired
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```typescript
|
|
414
|
+
* if (cache.has('important-key')) {
|
|
415
|
+
* // Key exists and is valid
|
|
416
|
+
* const value = cache.get('important-key');
|
|
417
|
+
* }
|
|
418
|
+
* ```
|
|
119
419
|
*/
|
|
120
420
|
has(key: K): boolean;
|
|
121
421
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
422
|
+
* Deletes a key from the cache.
|
|
423
|
+
*
|
|
424
|
+
* @description
|
|
425
|
+
* Removes an entry from the cache. Triggers the onEvict callback
|
|
426
|
+
* with reason 'manual'.
|
|
427
|
+
*
|
|
428
|
+
* @param key - The cache key to delete
|
|
429
|
+
*
|
|
124
430
|
* @returns true if the key was deleted, false if it didn't exist
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* cache.set('key', 'value');
|
|
435
|
+
* cache.delete('key'); // returns true
|
|
436
|
+
* cache.delete('key'); // returns false (already deleted)
|
|
437
|
+
* ```
|
|
125
438
|
*/
|
|
126
439
|
delete(key: K): boolean;
|
|
127
440
|
/**
|
|
128
|
-
*
|
|
441
|
+
* Clears all entries from the cache.
|
|
442
|
+
*
|
|
443
|
+
* @description
|
|
444
|
+
* Removes all entries and resets the byte counter. If an onEvict
|
|
445
|
+
* callback is configured, it's called for each entry with reason 'clear'.
|
|
446
|
+
*
|
|
447
|
+
* Does NOT reset statistics (use resetStats() for that).
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```typescript
|
|
451
|
+
* cache.set('a', 1);
|
|
452
|
+
* cache.set('b', 2);
|
|
453
|
+
* cache.clear();
|
|
454
|
+
* console.log(cache.size); // 0
|
|
455
|
+
* ```
|
|
129
456
|
*/
|
|
130
457
|
clear(): void;
|
|
131
458
|
/**
|
|
132
|
-
*
|
|
459
|
+
* Gets cache statistics.
|
|
460
|
+
*
|
|
461
|
+
* @description
|
|
462
|
+
* Returns current statistics about cache performance including
|
|
463
|
+
* hits, misses, item count, byte usage, evictions, and hit rate.
|
|
464
|
+
*
|
|
133
465
|
* @returns Current cache statistics
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* ```typescript
|
|
469
|
+
* const stats = cache.getStats();
|
|
470
|
+
* console.log(`Hit rate: ${stats.hitRate}%`);
|
|
471
|
+
* console.log(`Cache size: ${stats.count} items, ${stats.bytes} bytes`);
|
|
472
|
+
* console.log(`Evictions: ${stats.evictions}`);
|
|
473
|
+
* ```
|
|
134
474
|
*/
|
|
135
475
|
getStats(): CacheStats;
|
|
136
476
|
/**
|
|
137
|
-
*
|
|
477
|
+
* Resets cache statistics.
|
|
478
|
+
*
|
|
479
|
+
* @description
|
|
480
|
+
* Resets hit, miss, and eviction counters to zero.
|
|
481
|
+
* Does NOT clear cached data.
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* ```typescript
|
|
485
|
+
* // After warmup period, reset stats
|
|
486
|
+
* cache.resetStats();
|
|
487
|
+
* // Now stats reflect production traffic
|
|
488
|
+
* ```
|
|
138
489
|
*/
|
|
139
490
|
resetStats(): void;
|
|
140
491
|
/**
|
|
141
|
-
*
|
|
492
|
+
* Gets the number of items currently in the cache.
|
|
493
|
+
*
|
|
494
|
+
* @returns Current item count
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* console.log(`Cache has ${cache.size} items`);
|
|
499
|
+
* ```
|
|
142
500
|
*/
|
|
143
501
|
get size(): number;
|
|
144
502
|
/**
|
|
145
|
-
*
|
|
503
|
+
* Gets the current byte size of the cache.
|
|
504
|
+
*
|
|
505
|
+
* @returns Current size in bytes
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* ```typescript
|
|
509
|
+
* console.log(`Cache using ${cache.bytes} bytes`);
|
|
510
|
+
* ```
|
|
146
511
|
*/
|
|
147
512
|
get bytes(): number;
|
|
148
513
|
/**
|
|
149
|
-
*
|
|
514
|
+
* Gets all keys in the cache in LRU order.
|
|
515
|
+
*
|
|
516
|
+
* @description
|
|
517
|
+
* Returns keys from most recently used to least recently used.
|
|
518
|
+
* Does NOT affect LRU ordering.
|
|
519
|
+
*
|
|
520
|
+
* @returns Array of keys in LRU order (most recent first)
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```typescript
|
|
524
|
+
* cache.set('a', 1);
|
|
525
|
+
* cache.set('b', 2);
|
|
526
|
+
* cache.get('a');
|
|
527
|
+
* console.log(cache.keys()); // ['a', 'b']
|
|
528
|
+
* ```
|
|
150
529
|
*/
|
|
151
530
|
keys(): K[];
|
|
152
531
|
/**
|
|
153
|
-
*
|
|
532
|
+
* Gets all values in the cache in LRU order.
|
|
533
|
+
*
|
|
534
|
+
* @description
|
|
535
|
+
* Returns values from most recently used to least recently used.
|
|
536
|
+
* Does NOT affect LRU ordering.
|
|
537
|
+
*
|
|
538
|
+
* @returns Array of values in LRU order (most recent first)
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* const recentValues = cache.values();
|
|
543
|
+
* ```
|
|
154
544
|
*/
|
|
155
545
|
values(): V[];
|
|
156
546
|
/**
|
|
157
|
-
*
|
|
547
|
+
* Gets all entries in the cache in LRU order.
|
|
548
|
+
*
|
|
549
|
+
* @description
|
|
550
|
+
* Returns [key, value] pairs from most recently used to least recently used.
|
|
551
|
+
* Does NOT affect LRU ordering.
|
|
552
|
+
*
|
|
553
|
+
* @returns Array of [key, value] pairs in LRU order
|
|
554
|
+
*
|
|
555
|
+
* @example
|
|
556
|
+
* ```typescript
|
|
557
|
+
* for (const [key, value] of cache.entries()) {
|
|
558
|
+
* console.log(`${key}: ${value}`);
|
|
559
|
+
* }
|
|
560
|
+
* ```
|
|
158
561
|
*/
|
|
159
562
|
entries(): Array<[K, V]>;
|
|
160
563
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
564
|
+
* Peeks at a value without updating LRU order.
|
|
565
|
+
*
|
|
566
|
+
* @description
|
|
567
|
+
* Retrieves a value without marking it as recently used.
|
|
568
|
+
* Useful for inspection or when you don't want to affect eviction order.
|
|
569
|
+
*
|
|
570
|
+
* @param key - The cache key to peek at
|
|
571
|
+
*
|
|
163
572
|
* @returns The cached value or undefined if not found/expired
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```typescript
|
|
576
|
+
* // Check value without affecting LRU order
|
|
577
|
+
* const value = cache.peek('key');
|
|
578
|
+
* // This won't prevent 'key' from being evicted next
|
|
579
|
+
* ```
|
|
164
580
|
*/
|
|
165
581
|
peek(key: K): V | undefined;
|
|
166
582
|
/**
|
|
167
|
-
*
|
|
583
|
+
* Evicts expired entries from the cache.
|
|
584
|
+
*
|
|
585
|
+
* @description
|
|
586
|
+
* Scans all entries and removes those that have expired.
|
|
587
|
+
* Triggers onEvict callback with reason 'ttl' for each removed entry.
|
|
588
|
+
*
|
|
589
|
+
* Call this periodically if you need proactive cleanup of expired entries.
|
|
590
|
+
* Note: Expired entries are also cleaned up lazily on get().
|
|
591
|
+
*
|
|
168
592
|
* @returns Number of entries evicted
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* // Run periodic cleanup
|
|
597
|
+
* setInterval(() => {
|
|
598
|
+
* const pruned = cache.prune();
|
|
599
|
+
* if (pruned > 0) {
|
|
600
|
+
* console.log(`Pruned ${pruned} expired entries`);
|
|
601
|
+
* }
|
|
602
|
+
* }, 60000); // Every minute
|
|
603
|
+
* ```
|
|
169
604
|
*/
|
|
170
605
|
prune(): number;
|
|
171
606
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
607
|
+
* Resizes the cache to new limits.
|
|
608
|
+
*
|
|
609
|
+
* @description
|
|
610
|
+
* Updates the maxCount and/or maxBytes limits. If the current cache
|
|
611
|
+
* exceeds the new limits, evicts LRU items until within limits.
|
|
612
|
+
*
|
|
613
|
+
* @param options - New size limits (maxCount and/or maxBytes)
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* ```typescript
|
|
617
|
+
* // Reduce cache size under memory pressure
|
|
618
|
+
* cache.resize({ maxBytes: 10 * 1024 * 1024 }); // Reduce to 10MB
|
|
619
|
+
*
|
|
620
|
+
* // Increase limit when more memory is available
|
|
621
|
+
* cache.resize({ maxCount: 1000, maxBytes: 100 * 1024 * 1024 });
|
|
622
|
+
* ```
|
|
174
623
|
*/
|
|
175
624
|
resize(options: Pick<CacheOptions, 'maxCount' | 'maxBytes'>): void;
|
|
176
625
|
}
|
|
177
626
|
/**
|
|
178
|
-
*
|
|
627
|
+
* Creates a key serializer for complex key types.
|
|
628
|
+
*
|
|
629
|
+
* @description
|
|
630
|
+
* Helper function for creating serializers when using complex key types
|
|
631
|
+
* that need to be converted to/from strings.
|
|
632
|
+
*
|
|
633
|
+
* @param serialize - Function to convert key to string
|
|
634
|
+
* @param deserialize - Function to convert string back to key
|
|
635
|
+
*
|
|
636
|
+
* @returns Object with serialize and deserialize functions
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```typescript
|
|
640
|
+
* interface ObjectKey {
|
|
641
|
+
* repo: string;
|
|
642
|
+
* sha: string;
|
|
643
|
+
* }
|
|
644
|
+
*
|
|
645
|
+
* const keySerializer = createKeySerializer<ObjectKey>(
|
|
646
|
+
* (key) => `${key.repo}:${key.sha}`,
|
|
647
|
+
* (str) => {
|
|
648
|
+
* const [repo, sha] = str.split(':');
|
|
649
|
+
* return { repo, sha };
|
|
650
|
+
* }
|
|
651
|
+
* );
|
|
652
|
+
*
|
|
653
|
+
* // Use with cache
|
|
654
|
+
* const serializedKey = keySerializer.serialize({ repo: 'foo', sha: 'abc' });
|
|
655
|
+
* cache.set(serializedKey, value);
|
|
656
|
+
* ```
|
|
179
657
|
*/
|
|
180
658
|
export declare function createKeySerializer<K>(serialize: (key: K) => string, deserialize: (str: string) => K): {
|
|
181
659
|
serialize: (key: K) => string;
|
|
182
660
|
deserialize: (str: string) => K;
|
|
183
661
|
};
|
|
184
662
|
/**
|
|
185
|
-
* Default size calculator for common value types
|
|
663
|
+
* Default size calculator for common value types.
|
|
664
|
+
*
|
|
665
|
+
* @description
|
|
666
|
+
* Estimates the byte size of common JavaScript value types:
|
|
667
|
+
* - `null/undefined`: 0 bytes
|
|
668
|
+
* - `string`: 2 bytes per character (UTF-16)
|
|
669
|
+
* - `number`: 8 bytes
|
|
670
|
+
* - `boolean`: 4 bytes
|
|
671
|
+
* - `Uint8Array/ArrayBuffer`: actual byteLength
|
|
672
|
+
* - `object`: JSON-serialized length * 2
|
|
673
|
+
* - `unknown`: 8 bytes (default)
|
|
674
|
+
*
|
|
675
|
+
* For more accurate size calculation with specific types,
|
|
676
|
+
* provide a custom sizeCalculator in CacheOptions.
|
|
677
|
+
*
|
|
678
|
+
* @param value - The value to calculate size for
|
|
679
|
+
*
|
|
680
|
+
* @returns Estimated size in bytes
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* ```typescript
|
|
684
|
+
* defaultSizeCalculator('hello'); // 10 (5 chars * 2)
|
|
685
|
+
* defaultSizeCalculator(42); // 8
|
|
686
|
+
* defaultSizeCalculator(new Uint8Array(100)); // 100
|
|
687
|
+
* defaultSizeCalculator({ key: 'value' }); // ~30
|
|
688
|
+
* ```
|
|
186
689
|
*/
|
|
187
690
|
export declare function defaultSizeCalculator<T>(value: T): number;
|
|
188
691
|
//# sourceMappingURL=lru-cache.d.ts.map
|