new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Bun · all subjects

runtime/stream

13 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Bun.readableStreamToArray API signature

Bun.readableStreamToArray reads the contents of a ReadableStream into an array of chunks. It takes a ReadableStream as an argument and returns a Promise that resolves to an array. Usage: const stream = new ReadableStream(); const arr = await Bun.readableStreamToArray(stream);

ReadableStream to array conversion

The Bun.readableStreamToArray function is a utility for converting ReadableStream objects to arrays of chunks, with usage shown in the example: const stream = new ReadableStream(); const str = await Bun.readableStreamToArray(stream);

Bun.readableStreamToBlob API

Bun.readableStreamToBlob reads the contents of a ReadableStream into a Blob. It is an async function that takes a ReadableStream as its argument and returns a Promise that resolves to a Blob.

Convert ReadableStream to Blob example

const stream = new ReadableStream(); const blob = await Bun.readableStreamToBlob(stream);

Bun.readableStreamToArrayBuffer converts ReadableStream to ArrayBuffer

To convert a ReadableStream to a Buffer, use Bun.readableStreamToArrayBuffer to read the stream's contents into an ArrayBuffer, then create a Buffer that points to it. The function is async and returns an ArrayBuffer.

Convert ReadableStream to Buffer example

const stream = new ReadableStream(); const arrBuf = await Bun.readableStreamToArrayBuffer(stream); const nodeBuf = Buffer.from(arrBuf);

ReadableStream.json() method to parse stream as JSON

To read a ReadableStream and parse it as JSON, call the json() method on the stream. This returns a promise that resolves to the parsed JSON object. Example: const stream = new ReadableStream(); const json = await stream.json();

ReadableStream has conversion functions for multiple formats

Bun provides several conversion functions on ReadableStream to read its contents into other formats. Multiple conversion methods are available beyond json().

Bun.readableStreamToText signature and usage

Bun.readableStreamToText is an async function that reads the contents of a ReadableStream into a string. It takes a ReadableStream as an argument and returns a Promise that resolves to a string. Example usage: const stream = new ReadableStream(); const str = await Bun.readableStreamToText(stream);

ReadableStream conversion functions available

Bun provides multiple conversion functions for ReadableStream, including Bun.readableStreamToText. Other ReadableStream conversion functions are documented in the runtime/utils section under Bun.readableStreamTo.

Bun.readableStreamToArrayBuffer signature and usage

Bun.readableStreamToArrayBuffer is an async function that converts a ReadableStream to an ArrayBuffer. It takes a ReadableStream as its argument and returns a Promise that resolves to an ArrayBuffer. Example: const stream = new ReadableStream(); const buf = await Bun.readableStreamToArrayBuffer(stream);

Bun.readableStreamToBytes signature and usage

Bun.readableStreamToBytes is an async function that converts a ReadableStream directly to a Uint8Array. It takes a ReadableStream as its argument and returns a Promise that resolves to a Uint8Array. Example: const stream = new ReadableStream(); const uint8 = await Bun.readableStreamToBytes(stream);

Converting ReadableStream to Uint8Array via ArrayBuffer

To convert a ReadableStream to a Uint8Array, read its contents into an ArrayBuffer with Bun.readableStreamToArrayBuffer, then create a Uint8Array that points to the buffer.

Give your agent this brain