Options
All
  • Public
  • Public/Protected
  • All
Menu

Module util/GuardedStream

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

Const 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. If the input is already guarded nothing will happen.

    Type parameters

    • T: EventEmitter<T>

    Parameters

    • stream: T

      Stream that can potentially throw an error.

    Returns Guarded<T>

    The stream.

Const 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>