( fn: (...args: A) => Promise<R>, )
| 16 | } |
| 17 | |
| 18 | export 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. |
no test coverage detected