* 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)
| 292 | * @returns {Promise<string>} |
| 293 | */ |
| 294 | async 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. |
no test coverage detected
searching dependent graphs…