@metreeca/pipe - v0.9.11
    Preparing search index...

    Function reduce

    • Creates a sink reducing the stream to a single value without an initial value.

      Type Parameters

      • V

        The type of items in the stream

      Parameters

      • reducer: (accumulator: V, item: V) => V | Promise<V>

        The function to combine the accumulator with each item

      Returns Sink<V, V | undefined>

      A sink that reduces the stream to a single value, the first item for singleton streams, or undefined for empty streams

    • Creates a sink reducing the stream to a single value with an initial value.

      Type Parameters

      • V

        The type of items in the stream

      • R

        The type of the accumulated result

      Parameters

      • reducer: (accumulator: R, item: V) => R | Promise<R>

        The function to combine the accumulator with each item

      • initial: R

        The initial value for the accumulator

      Returns Sink<V, R>

      A sink that reduces the stream to a single value