series
asyncRuns async functions in series (one after another), passing results sequentially.
Signature
series<T>(tasks: (() => Promise<T>)[]): Promise<T[]>Parameters
| Name | Type | Description |
|---|---|---|
tasks | (() => Promise<T>)[] | Array of async functions to execute |
Returns
Promise<T[]> - Returns array of results
Examples
Sequential operations
import { series } from 'dashlite'
const results = await series([
async () => await step1(),
async () => await step2(),
async () => await step3()
])Ordered execution
import { series } from 'dashlite'
const tasks = [
() => delay(100, 'first'),
() => delay(200, 'second'),
() => delay(50, 'third')
]
const results = await series(tasks)
// => ['first', 'second', 'third']Available since version 1.2.0