MCPcopy Create free account
hub / github.com/arctic-cli/interface / defer

Function defer

packages/arctic/src/util/defer.ts:1–12  ·  view source on GitHub ↗
(
  fn: T,
)

Source from the content-addressed store, hash-verified

1export function defer<T extends () => void | Promise<void>>(
2 fn: T,
3): T extends () => Promise<void> ? { [Symbol.asyncDispose]: () => Promise<void> } : { [Symbol.dispose]: () => void } {
4 return {
5 [Symbol.dispose]() {
6 fn()
7 },
8 [Symbol.asyncDispose]() {
9 return Promise.resolve(fn())
10 },
11 } as any
12}

Callers 4

openFunction · 0.90
prompt.tsFile · 0.90
shellFunction · 0.90
executeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected