Returns an iterable that yields the source items or undefined when the source is empty.
undefined
Element type produced by the source iterable.
Source iterable whose contents are forwarded to the result when available.
A deferred iterable producing the original sequence or a single undefined when no elements exist.
const values = [..._defaultIfEmpty([1, 2, 3])];console.log(values); // [1, 2, 3] Copy
const values = [..._defaultIfEmpty([1, 2, 3])];console.log(values); // [1, 2, 3]
or using the curried version:
const values = [...pipeInto([], defaultIfEmpty<number>())];console.log(values); // [undefined] Copy
const values = [...pipeInto([], defaultIfEmpty<number>())];console.log(values); // [undefined]
Returns an iterable that yields the source items or
undefinedwhen the source is empty.