function all
all<O>(outcomes: ReadonlyArray<O>): Result<Exclude<O, Any>[], Extract<O, Any>>

Collects an array of outcomes into an array of values, short-circuiting on the first failure — the Result-shaped analogue of Promise.all.

Unlike Promise.all, nothing is in flight while this runs: the work already happened, so "short-circuit" only decides what is reported, never what is cancelled. When you need every failure rather than the first, use partition().

import * as Result from './index.ts';

import * as Failure from './failure.ts';
const loaded: Result.Result<{ name: string }, Failure.Any>[] = [{ name: 'esbuild-css' }];

const plugins = Result.all(loaded); // as in Config's resolvePlugins
if (Failure.is(plugins)) console.error(plugins.message); // the first failure, context intact

Type Parameters

Parameters

outcomes: ReadonlyArray<O>

Return Type

Result<Exclude<O, Any>[], Extract<O, Any>>

Usage

import { all } from "lib/result/result.ts";