Skip to content

all ​

ts
function ResultAsync.all(results: AwaitableResult<T, E>[]): ResultAsync<T[], E>

Combines multiple results into a single result. If all results are Ok, returns an Ok containing an array of all values. If any result is an Err, returns the first Err encountered.

Example ​

ts
await ResultAsync.all([ok(1), ok(2), ok(3)]);
// Ok<number[]>([1, 2, 3])

await ResultAsync.all([ok(1), err("fail"), ok(3)]);
// Err<string>("fail")