@wpkernel/pipeline / maybeAll
Function: maybeAll()
ts
function maybeAll<TValues>(values): MaybePromise<AwaitedTuple<TValues>>;Resolves an ordered collection of values and thenables.
If every entry is synchronous, this returns a new array immediately. If any entry is asynchronous, all captured thenables are adopted and the function returns a native Promise with Promise.all ordering and rejection semantics. Input order is preserved in both paths.
Each value crosses the same read-once boundary as isPromiseLike. A throwing getter remains a synchronous throw.
Type Parameters
TValues
TValues extends readonly unknown[]
Parameters
values
TValues
Ordered values to resolve.
Returns
MaybePromise<AwaitedTuple<TValues>>
A new array directly, or a native promise when any entry is asynchronous.
Example
ts
const immediate = maybeAll([1, 2, 3]);
isPromiseLike(immediate); // false
const deferred = maybeAll([1, Promise.resolve(2), 3]);
isPromiseLike(deferred); // true