Function guardStream

  • Makes sure that listeners always receive the error event of a stream, even if it was thrown before the listener was attached.

    When guarding a stream it is assumed that error listeners already attached should be ignored, only error listeners attached after the stream is guarded will prevent an error from being logged.

    If the input is already guarded the guard will be reset, which means ignoring error listeners already attached.

    Type Parameters

    • T extends EventEmitter<T>

    Parameters

    • stream: T

      Stream that can potentially throw an error.

    Returns Guarded<T>

    The stream.