@adviser/cement - v0.0.0
    Preparing search index...

    Function stream2array

    • Converts a ReadableStream to an array by collecting all chunks.

      Reads the entire stream into memory, collecting all chunks into an array. Use with caution on large or infinite streams as it loads everything into memory.

      Type Parameters

      • T

        Stream element type

      Parameters

      • a: ReadableStream<T>

        ReadableStream to convert

      Returns Promise<T[]>

      Promise resolving to array of all stream chunks

      const stream = fetchDataStream();
      const items = await stream2array(stream);
      console.log(`Received ${items.length} items`);

      // Process stream as array
      const numbers = await stream2array(numberStream);
      const sum = numbers.reduce((a, b) => a + b, 0);