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.
Parameters
Section titled “Parameters”stream
Section titled “stream”ReadableStream<Uint8Array<ArrayBufferLike>>
The byte stream to read
encoding
Section titled “encoding”string = 'utf-8'
Text encoding (default: ‘utf-8’)
Returns
Section titled “Returns”Promise<string>
Promise resolving to the decoded string
Example
Section titled “Example”const bytes = await ctx.readFile('config.json')const text = await streamToString(bytes)const data = JSON.parse(text)