Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/streams/to_text.ts>toText

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function toText
import { toText } from "https://deno.land/std@0.220.0/streams/to_text.ts";

Converts a ReadableSteam of strings or Uint8Arrays to a single string. Works the same as Response.text.

Examples

Example 1

import { toText } from "https://deno.land/std@0.220.0/streams/to_text.ts";

const stream = ReadableStream.from(["Hello, ", "world!"]);
await toText(stream); // "Hello, world!"

Parameters

readableStream: ReadableStream

Returns

Promise<string>