Skip to content

streamToString

streamToString(stream, encoding): Promise<string>

Defined in: common.ts:53

Convert a byte stream to a string.

Reads all chunks from the stream and decodes them as text. Useful for transforms that need to process text content.

ReadableStream<Uint8Array<ArrayBufferLike>>

The byte stream to read

string = 'utf-8'

Text encoding (default: ‘utf-8’)

Promise<string>

Promise resolving to the decoded string

const bytes = await ctx.readFile('config.json')
const text = await streamToString(bytes)
const data = JSON.parse(text)