Fbytes
Bun

function

stream.consumers.bytes

function bytes(
stream: ReadableStream | AsyncIterable<any, any, any> | ReadableStream<any>
): Promise<NonSharedUint8Array>;
import { bytes } from 'node:stream/consumers';
import { Readable } from 'node:stream';
import { Buffer } from 'node:buffer';

const dataBuffer = Buffer.from('hello world from consumers!');

const readable = Readable.from(dataBuffer);
const data = await bytes(readable);
console.log(`from readable: ${data.length}`);
// Prints: from readable: 27
@returns

Fulfills with a Uint8Array containing the full contents of the stream.

Referenced types

interface ReadableStream<R = any>