(chunk: string | Uint8Array)
| 329 | } |
| 330 | }) |
| 331 | function onData(chunk: string | Uint8Array) { |
| 332 | if (typeof chunk === "string") { |
| 333 | string += chunk |
| 334 | bytes += Buffer.byteLength(chunk, decodes ? encoding : "utf8") |
| 335 | } else { |
| 336 | string += decoder.write(chunk) |
| 337 | bytes += chunk.byteLength |
| 338 | } |
| 339 | if (maxBytesNumber !== undefined && bytes > maxBytesNumber) { |
| 340 | stream.off("data", onData) |
| 341 | if (options?.destroyOnOverflow === false) { |
| 342 | drainReadable(stream, cleanup) |
| 343 | } else { |
| 344 | destroyReadable(stream, cleanup) |
| 345 | } |
| 346 | resume(Effect.fail(onError(new MaxBytesError(maxBytesNumber)) as E)) |
| 347 | } |
| 348 | } |
| 349 | stream.on("data", onData) |
| 350 | return Effect.sync(() => { |
| 351 | stream.off("data", onData) |
nothing calls this directly
no test coverage detected