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

Function textSync

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

* Collect and decode text from a sync source. * @param {Iterable } source * @param {{ encoding?: string, limit?: number }} [options] * @returns {string}

(source, options = kNullPrototype)

Source from the content-addressed store, hash-verified

238 * @returns {string}
239 */
240function textSync(source, options = kNullPrototype) {
241 validateSyncConsumerOptions(options);
242 const data = concatBytes(collectSync(source, options.limit));
243 const decoder = new TextDecoder(options.encoding ?? 'utf-8', {
244 __proto__: null,
245 fatal: true,
246 });
247 return decoder.decode(data);
248}
249
250/**
251 * Collect bytes as ArrayBuffer from a sync source.

Callers 15

testSyncShareDisposeFunction · 0.85
testTextSyncSABFunction · 0.85
testBasicPullSyncFunction · 0.85
testLargeFileFunction · 0.85
testAutoCloseFunction · 0.85
testNoAutoCloseFunction · 0.85

Calls 4

decodeMethod · 0.95
concatBytesFunction · 0.85
collectSyncFunction · 0.85

Tested by

no test coverage detected