Documentation
    Preparing search index...

    Function fromCollection

    • Creates a readable stream from an collection of values.

      Type Parameters

      • T

      Parameters

      • collection:
            | Iterator<T, any, any>
            | Iterable<T, any, any>
            | AsyncIterator<T, any, any>
            | AsyncIterable<T, any, any>
            | ArrayLike<T>
      • OptionalqueuingStrategy: QueuingStrategy<T>

      Returns ReadableStream<T>

      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]-|
    • Creates a readable stream from an collection of values.

      Type Parameters

      • T extends Record<string | symbol, unknown>

      Parameters

      • collection: T
      • OptionalqueuingStrategy: QueuingStrategy<T>

      Returns ReadableStream<Entries<T>>

      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]-|