Function slack

  • Add job control and buffering to a stream

    This lets you block events from a stream that can't be paused, or allow for some slack for a source that can sometimes get ahead of its sink.

    Type Parameters

    • T

    Parameters

    • size: number

      The number of items to buffer when the sink is busy (i.e., the sink is running or the connection is paused). If positive, the most recent N items are kept (a "sliding" buffer), and if negative, the oldest N item are kept (a "dropping" buffer). If zero, no items are buffered, and items are dropped if received while the sink is busy.

    • dropped: Sink<T> = noop

      Optional: a callback that will receive items when they are dropped. (Useful for testing, performance instrumentation, error logging, etc.)

    Returns Transformer<T>