-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
33 lines (31 loc) · 957 Bytes
/
types.ts
File metadata and controls
33 lines (31 loc) · 957 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
/**
* @fileoverview 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
}