diff options
Diffstat (limited to 'cli/js/buffer.ts')
-rw-r--r-- | cli/js/buffer.ts | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/cli/js/buffer.ts b/cli/js/buffer.ts index 8389db4f9..473affe3d 100644 --- a/cli/js/buffer.ts +++ b/cli/js/buffer.ts @@ -158,38 +158,30 @@ export class Buffer implements Reader, ReaderSync, Writer, WriterSync { async readFrom(r: Reader): Promise<number> { let n = 0; while (true) { - try { - const i = this.#grow(MIN_READ); - this.#reslice(i); - const fub = new Uint8Array(this.#buf.buffer, i); - const nread = await r.read(fub); - if (nread === null) { - return n; - } - this.#reslice(i + nread); - n += nread; - } catch (e) { + const i = this.#grow(MIN_READ); + this.#reslice(i); + const fub = new Uint8Array(this.#buf.buffer, i); + const nread = await r.read(fub); + if (nread === null) { return n; } + this.#reslice(i + nread); + n += nread; } } readFromSync(r: ReaderSync): number { let n = 0; while (true) { - try { - const i = this.#grow(MIN_READ); - this.#reslice(i); - const fub = new Uint8Array(this.#buf.buffer, i); - const nread = r.readSync(fub); - if (nread === null) { - return n; - } - this.#reslice(i + nread); - n += nread; - } catch (e) { + const i = this.#grow(MIN_READ); + this.#reslice(i); + const fub = new Uint8Array(this.#buf.buffer, i); + const nread = r.readSync(fub); + if (nread === null) { return n; } + this.#reslice(i + nread); + n += nread; } } } |