Executes asynchronous tasks sequentially, passing the result of each task as input to the next one (waterfall pattern).
Type of the initial input value.
An array of async functions, each receiving the previous result as input.
The initial input value for the first task.
A promise resolving to the final task’s result.
const tasks = [ async (x: number) => x + 1, async (x: number) => x * 2, async (x: number) => x - 3];const result = await waterfall(tasks, 5);console.log(result); // ((5 + 1) * 2) - 3 = 9 Copy
const tasks = [ async (x: number) => x + 1, async (x: number) => x * 2, async (x: number) => x - 3];const result = await waterfall(tasks, 5);console.log(result); // ((5 + 1) * 2) - 3 = 9
1.1.0
Executes asynchronous tasks sequentially, passing the result of each task as input to the next one (waterfall pattern).