MCPcopy Index your code
hub / github.com/nodejs/node / text

Function text

lib/stream/consumers.js:66–79  ·  view source on GitHub ↗

* @param {AsyncIterable|ReadableStream|Readable} stream * @returns {Promise }

(stream)

Source from the content-addressed store, hash-verified

64 * @returns {Promise<string>}
65 */
66async function text(stream) {
67 const dec = new TextDecoder();
68 let str = '';
69 for await (const chunk of stream) {
70 if (typeof chunk === 'string')
71 str += chunk;
72 else
73 str += dec.decode(chunk, { stream: true });
74 }
75 // Flush the streaming TextDecoder so that any pending
76 // incomplete multibyte characters are handled.
77 str += dec.decode(undefined, { stream: false });
78 return str;
79}
80
81/**
82 * @param {AsyncIterable|ReadableStream|Readable} stream

Callers 1

jsonFunction · 0.70

Calls 1

decodeMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…