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

Function memoizeThunk

packages/effect/src/SchemaAST.ts:3021–3032  ·  view source on GitHub ↗
(f: () => A)

Source from the content-addressed store, hash-verified

3019
3020/** @internal */
3021export function memoizeThunk<A>(f: () => A): () => A {
3022 let done = false
3023 let a: A
3024 return () => {
3025 if (done) {
3026 return a
3027 }
3028 a = f()
3029 done = true
3030 return a
3031 }
3032}
3033
3034/**
3035 * AST node for lazy/recursive schemas.

Callers 1

constructorMethod · 0.85

Calls 1

fFunction · 0.50

Tested by

no test coverage detected