MCPcopy Create free account
hub / github.com/middleapi/orpc / sequential

Function sequential

packages/shared/src/function.ts:18–28  ·  view source on GitHub ↗
(
  fn: (...args: A) => Promise<R>,
)

Source from the content-addressed store, hash-verified

16}
17
18export function sequential<A extends any[], R>(
19 fn: (...args: A) => Promise<R>,
20): (...args: A) => Promise<R> {
21 let lastOperationPromise: Promise<any> = Promise.resolve()
22
23 return (...args: A): Promise<R> => {
24 return lastOperationPromise = lastOperationPromise.catch(() => { }).then(() => {
25 return fn(...args)
26 })
27 }
28}
29
30/**
31 * Executes the callback function after the current call stack has been cleared.

Callers 2

function.test.tsFile · 0.90
constructorMethod · 0.90

Calls 1

thenMethod · 0.80

Tested by

no test coverage detected