(fn: T)
| 1 | export type AnyFunction = (...args: any[]) => any |
| 2 | |
| 3 | export 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 | |
| 18 | export function sequential<A extends any[], R>( |
| 19 | fn: (...args: A) => Promise<R>, |
no outgoing calls
no test coverage detected