ts-iterable-functions
    Preparing search index...

    Function _defaultIfEmpty

    • Returns an iterable that yields the source items or undefined when the source is empty.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • src: Iterable<T>

        Source iterable whose contents are forwarded to the result when available.

      Returns Iterable<T | undefined>

      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]

      or using the curried version:

      const values = [...pipeInto([], defaultIfEmpty<number>())];
      console.log(values); // [undefined]