-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
45 lines (43 loc) · 1005 Bytes
/
types.ts
File metadata and controls
45 lines (43 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @file Public type surface for `memo/*` modules — `MemoizeOptions` is the
* user-facing options bag accepted by every memoize entrypoint,
* `CacheEntry<T>` is the internal row stored in each per-function cache. Pure
* types, no runtime side effects.
*/
/**
* Options for memoization behavior.
*/
export type MemoizeOptions<Args extends unknown[]> = {
/**
* Custom cache key generator (defaults to JSON.stringify)
*/
keyGen?: (...args: Args) => string
/**
* Maximum cache size (LRU eviction when exceeded)
*/
maxSize?: number
/**
* TTL in milliseconds (cache entries expire after this time)
*/
ttl?: number
/**
* Cache name for debugging.
*/
name?: string
/**
* Weak cache for object keys (enables GC)
*/
weak?: boolean
/**
* Custom equality check for cache hits.
*/
equals?: (a: Args, b: Args) => boolean
}
/**
* Cache entry with metadata.
*/
export type CacheEntry<T> = {
value: T
timestamp: number
hits: number
}