| 1247 | } |
| 1248 | |
| 1249 | _transform (chunk, encoding, callback) { |
| 1250 | if (!this._inflateStream) { |
| 1251 | if (chunk.length === 0) { |
| 1252 | callback() |
| 1253 | return |
| 1254 | } |
| 1255 | this._inflateStream = (chunk[0] & 0x0F) === 0x08 |
| 1256 | ? zlib.createInflate(this.#zlibOptions) |
| 1257 | : zlib.createInflateRaw(this.#zlibOptions) |
| 1258 | |
| 1259 | this._inflateStream.on('data', this.push.bind(this)) |
| 1260 | this._inflateStream.on('end', () => this.push(null)) |
| 1261 | this._inflateStream.on('error', (err) => this.destroy(err)) |
| 1262 | } |
| 1263 | |
| 1264 | this._inflateStream.write(chunk, encoding, callback) |
| 1265 | } |
| 1266 | |
| 1267 | _final (callback) { |
| 1268 | if (this._inflateStream) { |