Options
All
  • Public
  • Public/Protected
  • All
Menu

Module util/StreamUtil

Index

Functions

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>

pipeSafely

  • pipeSafely<T>(readable: ReadableStream, destination: T, mapError?: (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<T>

    Parameters

    • readable: ReadableStream

      Initial readable stream.

    • destination: T

      The destination for writing data.

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

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

        • (error: Error): Error
        • Parameters

          • error: Error

          Returns Error

    Returns Guarded<T>

    The destination stream.

readableToString

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

    Parameters

    • stream: Readable

      Stream of strings.

    Returns Promise<string>

    The joined string.