MCPcopy Create free account
hub / github.com/anomalyco/opencode / readonlyMap

Function readonlyMap

packages/schema/src/event.ts:110–125  ·  view source on GitHub ↗
(map: Map<Key, Value>)

Source from the content-addressed store, hash-verified

108}
109
110function readonlyMap<Key, Value>(map: Map<Key, Value>): ReadonlyMap<Key, Value> {
111 const result: ReadonlyMap<Key, Value> = Object.freeze({
112 get size() {
113 return map.size
114 },
115 entries: () => map.entries(),
116 forEach: (callback: (value: Value, key: Key, map: ReadonlyMap<Key, Value>) => void, thisArg?: unknown) =>
117 map.forEach((value, key) => callback.call(thisArg, value, key, result)),
118 get: (key: Key) => map.get(key),
119 has: (key: Key) => map.has(key),
120 keys: () => map.keys(),
121 values: () => map.values(),
122 [Symbol.iterator]: () => map[Symbol.iterator](),
123 })
124 return result
125}

Callers 2

latestFunction · 0.85
durableFunction · 0.85

Calls 2

getMethod · 0.65
valuesMethod · 0.45

Tested by

no test coverage detected