* Collect and decode text from a sync source. * @param {Iterable } source * @param {{ encoding?: string, limit?: number }} [options] * @returns {string}
(source, options = kNullPrototype)
| 238 | * @returns {string} |
| 239 | */ |
| 240 | function 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. |
no test coverage detected