UNPKG

actionhero

Version:

actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks

34 lines (33 loc) 942 B
/** * In series, run an array of `async` functions * * without arguments * ```js * let sleepyFunc = async () => { * await new Promise((resolve) => { setTimeout(resolve, 100) }) * return (new Date()).getTime() * } * let jobs = [sleepyFunc, sleepyFunc, sleepyFunc] * let responses = await api.utils.asyncWaterfall(jobs) * // responses = [1506536188356, 1506536188456, 1506536188456] * ``` * * with arguments * ```js * let sleepyFunc = async (response) => { * await new Promise((resolve) => { setTimeout(resolve, 100) }) * return response * } * let jobs = [ * {method: sleepyFunc, args: ['a']}, * {method: sleepyFunc, args: ['b']}, * {method: sleepyFunc, args: ['c']} * ] * let responses = await api.utils.asyncWaterfall(jobs) * // responses = ['a', 'b', 'c'] * ``` */ export declare function asyncWaterfall(jobs: Array<Function | { method: Function; args: Array<any>; }>): Promise<Array<any>>;