Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "util/GuardedStream"

Index

Type aliases

Guarded

Guarded<T>: T & Guard

A stream that is guarded. This means that if this stream emits an error before a listener is attached, it will store the error and emit it once a listener is added.

Type parameters

  • T: EventEmitter

Variables

Let attachDefaultErrorListener

attachDefaultErrorListener: (this: StoredErrorStream, event: string) => void

Type declaration

Const errorGuard

errorGuard: unique symbol = Symbol('error')

Const guard

guard: unique symbol = Symbol('guard')

Const logger

logger: Logger = getLoggerFor('GuardedStream')

Const timeoutGuard

timeoutGuard: unique symbol = Symbol('timeout')

Functions

Const defaultErrorListener

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

    Parameters

    • stream: T

      Stream that can potentially throw an error.

    Returns Guarded<T>

    The wrapped stream.

Const removeDefaultErrorListener

  • Callback that is used when a new listener is attached to remove the current error-related fallback functions, or to emit an error if one was thrown in the meantime.

    Parameters

    Returns void