Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "util/StreamUtil"

Index

Variables

Const logger

logger: Logger = getLoggerFor('StreamUtil')

Functions

Const guardedStreamFrom

  • guardedStreamFrom(iterable: Iterable<any>, options?: ReadableOptions): Guarded<Readable>
  • Converts an iterable to a stream and applies an error guard so that it is Guarded.

    Parameters

    • iterable: Iterable<any>

      Data to stream.

    • Optional options: ReadableOptions

      Options to pass to the Readable constructor. See {@link Readable.from}.

    Returns Guarded<Readable>

Const pipeSafely

  • pipeSafely<T>(readable: ReadableStream, destination: T, mapError?: undefined | ((error: Error) => Error)): Guarded<T>
  • Pipes one stream into another and emits errors of the first stream with the second. In case of an error in the first stream the second one will be destroyed with the given error. This will also make the stream Guarded.

    Type parameters

    • T: Writable

    Parameters

    • readable: ReadableStream

      Initial readable stream.

    • destination: T

      The destination for writing data.

    • Optional mapError: undefined | ((error: Error) => Error)

      Optional function that takes the error and converts it to a new error.

    Returns Guarded<T>

    The destination stream.

Const readableToString

  • readableToString(stream: Readable): Promise<string>
  • Joins all strings of a stream.

    Parameters

    • stream: Readable

      Stream of strings.

    Returns Promise<string>

    The joined string.