Function fromCollection

  • Creates a readable stream from an collection of values.

    Type Parameters

    • T

    Parameters

    • collection: Iterator<T, any, undefined> | Iterable<T> | AsyncIterator<T, any, undefined> | AsyncIterable<T> | ArrayLike<T>
    • Optional queuingStrategy: QueuingStrategy<T>

    Returns ReadableStream<T>

    Example

    Using an Iterable

    fromCollection([1, 2, 3, 4])
    

    Using an AsyncIterable

    fromCollection((async function* () {
    yield 1
    })())

    Using an ArrayLike

    fromCollection({
    0: 'zero',
    1: 'one',
    2: 'two',
    length: 3,
    })

    Streaming object entries

    fromCollection({
    one: 1,
    two: 2,
    three: 3,
    })
    // -[one, 1]-[two, 2]-[threee, 3]-|
  • Type Parameters

    • T extends Record<string | symbol, unknown>

    Parameters

    • collection: T
    • Optional queuingStrategy: QueuingStrategy<T>

    Returns ReadableStream<Entries<T>>

Generated using TypeDoc