MCPcopy Index your code
hub / github.com/middleapi/orpc / once

Function once

packages/shared/src/function.ts:3–16  ·  view source on GitHub ↗
(fn: T)

Source from the content-addressed store, hash-verified

1export type AnyFunction = (...args: any[]) => any
2
3export function once<T extends () => any>(fn: T): () => ReturnType<T> {
4 let cached: { result: ReturnType<T> } | undefined
5
6 return (): ReturnType<T> => {
7 if (cached) {
8 return cached.result
9 }
10
11 const result = fn()
12 cached = { result }
13
14 return result
15 }
16}
17
18export function sequential<A extends any[], R>(
19 fn: (...args: A) => Promise<R>,

Callers 13

toStandardLazyResponseFunction · 0.90
toStandardLazyRequestFunction · 0.90
toStandardLazyRequestFunction · 0.90
subscribeListenerMethod · 0.90
subscribeListenerMethod · 0.90
toStandardLazyRequestFunction · 0.90
initMethod · 0.90
toStandardLazyRequestFunction · 0.90
function.test.tsFile · 0.90
replicateAsyncIteratorFunction · 0.90
subscribeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected