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

Function text

lib/internal/streams/iter/consumers.js:294–303  ·  view source on GitHub ↗

* Collect and decode text from an async or sync source. * @param {AsyncIterable |Iterable } source * @param {{ encoding?: string, signal?: AbortSignal, limit?: number }} [options] * @returns {Promise }

(source, options = kNullPrototype)

Source from the content-addressed store, hash-verified

292 * @returns {Promise<string>}
293 */
294async function text(source, options = kNullPrototype) {
295 validateConsumerOptions(options);
296 const chunks = await collectAsync(source, options.signal, options.limit);
297 const data = concatBytes(chunks);
298 const decoder = new TextDecoder(options.encoding ?? 'utf-8', {
299 __proto__: null,
300 fatal: true,
301 });
302 return decoder.decode(data);
303}
304
305/**
306 * Collect bytes as ArrayBuffer from an async or sync source.

Calls 4

decodeMethod · 0.95
validateConsumerOptionsFunction · 0.85
collectAsyncFunction · 0.85
concatBytesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…