MCPcopy
hub / github.com/Effect-TS/effect / globalValue

Function globalValue

packages/effect/src/GlobalValue.ts:42–53  ·  view source on GitHub ↗
(id: unknown, compute: () => A)

Source from the content-addressed store, hash-verified

40 * @since 2.0.0
41 */
42export const globalValue = <A>(id: unknown, compute: () => A): A => {
43 if (!globalStore) {
44 // @ts-expect-error
45 globalThis[globalStoreId] ??= new Map()
46 // @ts-expect-error
47 globalStore = globalThis[globalStoreId] as Map<unknown, any>
48 }
49 if (!globalStore.has(id)) {
50 globalStore.set(id, compute())
51 }
52 return globalStore.get(id)!
53}

Callers 15

workerRunner.tsFile · 0.90
httpClient.tsFile · 0.90
SqliteClient.tsFile · 0.90
statement.tsFile · 0.90
command.tsFile · 0.90
SqliteClient.tsFile · 0.90
HttpApiClient.tsFile · 0.90
HttpApiSchema.tsFile · 0.90
HttpApiBuilder.tsFile · 0.90
Socket.tsFile · 0.90
OpenApi.tsFile · 0.90
Headers.tsFile · 0.90

Calls 2

setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…