partitionResults
Separate an array of Results into success values and errors. Every outcome is retained, in its original order within each group. Similar to Rust's itertools::Itertools::partition_result, but returns named fields rather than a tuple.
Usage
partitionResults(results)
Parameters
The already-created Results to separate. Accepts readonly arrays and does not mutate inputs.
Returns
A plain object, not a Result. Both arrays are new; their elements retain the original value and error references. Typed error fields and distinct error unions are preserved, with no normalization. An all-success input has an empty errors array; an all-failure input has an empty values array. Successful null and undefined values stay in values.
Batch processing
Use this when partial success is meaningful: process valid rows while reporting every rejected row. If you need source positions, attach row metadata to the value or domain error before partitioning; cross-group positions are not retained automatically.
All input operations have already executed. This helper neither catches exceptions nor awaits Promises. Wrap unsafe row parsing with attempt, or await asynchronous Results before partitioning.
See also
collectResults— require all successes, returning only the first failureisOk/isErr— narrow individual Results- Result & Errors