Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

Functions

Type aliases

Guarded

Guarded<T>: T & Guard

A stream that is guarded from emitting errors when there are no listeners. If an error occurs while no listener is attached, it will store the error and emit it once a listener is added (or a timeout occurs).

Type parameters

  • T: NodeJS.EventEmitter = NodeJS.EventEmitter

Functions

guardStream

  • guardStream<T>(stream: T): Guarded<T>
  • 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: EventEmitter<T>

    Parameters

    • stream: T

      Stream that can potentially throw an error.

    Returns Guarded<T>

    The stream.

isGuarded

  • isGuarded<T>(stream: T): stream is Guarded<T>
  • Determines whether the stream is guarded from emitting errors.

    Type parameters

    • T: EventEmitter<T>

    Parameters

    • stream: T

    Returns stream is Guarded<T>