import { text } from 'node:stream/consumers';
import { Readable } from 'node:stream';
const readable = Readable.from('Hello world from consumers!');
const data = await text(readable);
console.log(`from readable: ${data.length}`);
// Prints: from readable: 27
function
stream.consumers.text
stream: ReadableStream | AsyncIterable<any, any, any> | ReadableStream<any>
): Promise<string>;
@returns
Fulfills with the contents of the stream parsed as a UTF-8 encoded string.
Referenced types
interface ReadableStream<R = any>
- ): ReadableStream<T>;