Tela SDK for JavaScript
    Preparing search index...

    Class Stream<Item>

    Represents a stream of items that can be asynchronously iterated over.

    Type Parameters

    • Item

    Implements

    Index

    Constructors

    • Creates a new Stream instance.

      Type Parameters

      • Item

      Parameters

      • iterator: () => AsyncIterator<Item>

        A function that returns an AsyncIterator.

      • controller: AbortController

        The AbortController for this stream.

      • OptionalrequestId: string

      Returns Stream<Item>

    Properties

    controller: AbortController

    The AbortController for this stream.

    requestId?: string

    Methods

    • Implements the AsyncIterable interface, allowing the Stream to be used in a for-await-of loop.

      Returns AsyncIterator<Item>

      An AsyncIterator for the stream items.

    • Splits the stream into two streams which can be independently read from at different speeds.

      Returns [Stream<Item>, Stream<Item>]

      A tuple containing two new Stream instances.

    • Converts this stream to a newline-separated ReadableStream of JSON stringified values. The resulting stream can be converted back to a Stream using Stream.fromReadableStream().

      Returns ReadableStream

      A ReadableStream containing newline-separated JSON data.

    • Creates a Stream from a newline-separated ReadableStream where each item is a JSON value.

      Type Parameters

      • Item

      Parameters

      • readableStream: ReadableStream

        The ReadableStream containing newline-separated JSON data.

      • controller: AbortController

        The AbortController for this stream.

      Returns Stream<Item>

      A new Stream instance.

      If the stream is consumed more than once.

    • Creates a Stream from a server-sent events (SSE) Response.

      Type Parameters

      • Item

      Parameters

      • response: Response

        The Response object containing the SSE data.

      • controller: AbortController

        The AbortController for this stream.

      Returns Stream<Item>

      A new Stream instance.

      If the stream is consumed more than once.

      If the SSE data contains an error.