* @param {string} [encoding] * @param {{ * fatal? : boolean, * ignoreBOM? : boolean, * }} [options]
(encoding = 'utf-8', options = kEmptyObject)
| 131 | * }} [options] |
| 132 | */ |
| 133 | constructor(encoding = 'utf-8', options = kEmptyObject) { |
| 134 | this.#handle = new TextDecoder(encoding, options); |
| 135 | this.#transform = new TransformStream({ |
| 136 | transform: (chunk, controller) => { |
| 137 | if (chunk === undefined) { |
| 138 | throw new ERR_INVALID_ARG_TYPE('chunk', 'string', chunk); |
| 139 | } |
| 140 | const value = this.#handle.decode(chunk, { stream: true }); |
| 141 | if (value) |
| 142 | controller.enqueue(value); |
| 143 | }, |
| 144 | flush: (controller) => { |
| 145 | const value = this.#handle.decode(); |
| 146 | if (value) |
| 147 | controller.enqueue(value); |
| 148 | controller.terminate(); |
| 149 | }, |
| 150 | }); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * @readonly |