MCPcopy Create free account
hub / github.com/Effect-TS/effect / setWithEviction

Function setWithEviction

packages/platform/cloudflare/src/internal/boundedMap.ts:9–15  ·  view source on GitHub ↗
(map: Map<K, V>, key: K, value: V, capacity: number)

Source from the content-addressed store, hash-verified

7 * @internal
8 */
9export const setWithEviction = <K, V>(map: Map<K, V>, key: K, value: V, capacity: number): void => {
10 map.delete(key)
11 map.set(key, value)
12 if (map.size <= capacity) return
13 const oldest = map.keys().next().value
14 if (oldest !== undefined) map.delete(oldest)
15}

Callers 2

handleFromClientFunction · 0.90
interruptFunction · 0.90

Calls 4

keysMethod · 0.80
deleteMethod · 0.65
setMethod · 0.65
nextMethod · 0.65

Tested by

no test coverage detected