partition<O>(outcomes: ReadonlyArray<O>): { values: Exclude<O, Any>[]; errors: Extract<O, Any>[]; }
Splits outcomes into their successes and their failures, keeping both.
This is the shape most batch work actually wants, and the one Promise.all cannot give
you: a rejected Promise.all discards the settled successes alongside the other
failures. Task.results produces exactly the array this consumes.
import * as Result from './index.ts'; import { Task } from '../task/index.ts'; import * as Failure from './failure.ts'; const Rejected = Failure.define('Rejected', (d: { path: string }) => `rejected ${d.path}`); const load = (path: string) => Task<string, Failure.Of<typeof Rejected>>(() => { if (!path.startsWith('a')) throw Rejected({ path }); return path; }); const outcomes = await Task.results(['a.json', 'b.json'].map(load)); const { values, errors } = Result.partition(outcomes); // ['a.json'] / [Failure(Rejected)]
outcomes: ReadonlyArray<O>