Function defaultEmpty

  • Adds a default value, iterator or iterable to an empty pipeline.

    If the pipeline has at least one value, the defaults are ignored.

    import {pipe, defaultEmpty} from 'iter-ops';

    const i = pipe(
    [], // empty iterable/pipeline
    defaultEmpty([1, 2, 3]) // default for an empty pipeline
    );

    console.log(...i); //=> 1, 2, 3

    Note that if you add asynchronous defaults into a synchronous pipeline, they will be processed as simple values.

    Type Parameters

    • T

    • D

    Parameters

    Returns Operation<T, T | D>

  • Adds a default value, iterator or iterable to an empty pipeline.

    Type Parameters

    • T

    • D

    Parameters

    Returns Operation<T, T | D>

  • Adds a default value, iterator or iterable to an empty pipeline.

    Type Parameters

    • T

    • D

    Parameters

    • value: D

    Returns Operation<T, T | D>