• Run a restarting() callback for each value produced by a source.

    With each event that occurs, any previous callback run is cleaned up before the new one begins. (And the last run is cleaned up when the connection or job ends.)

    This function is almost the exact opposite of each(), in that the stream is never paused (unless you do so manually via a throttle or inlet), and if the "loop body" (callback job) is still running when a new value arrives, forEach() restarts the job instead of dropping the value.

    Type Parameters

    • T

    Parameters

    • src: Stream<T>

      An event source (i.e. a Source or Signal)

    • sink: Sink<T>

      A callback that receives values from the source

    • Optional inlet: Inlet

      An optional throttle or inlet that will be used to pause the source (if it's a signal or supports backpressure)

    Returns Connection

    a Connection that can be used to detect the stream end/error, or ended to close it early.

  • When called without a source, return a callback suitable for use w/pipe(). e.g.:

    pipe(someSource, ..., forEach(v => { doSomething(v); }), optionalInlet));
    

    Type Parameters

    • T

    Parameters

    Returns ((src: Stream<T>) => Connection)