Skip to content

Function: serial()

ts
function serial<T>(factories): Promise<T[]>;

Runs an array of async factories one after another, collecting results. 依次运行一组异步工厂函数并收集结果。

Type Parameters

Type Parameter
T

Parameters

ParameterType
factories() => Promise<T>[]

Returns

Promise<T[]>

Example

ts
const results = await serial([() => Promise.resolve(1), () => Promise.resolve(2), () => Promise.resolve(3)])
results // => [1, 2, 3]

Since

1.0.0

Released under the MIT License.