diff options
Diffstat (limited to 'std/io/bufio.ts')
-rw-r--r-- | std/io/bufio.ts | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/std/io/bufio.ts b/std/io/bufio.ts index cd2573683..a1e6f67aa 100644 --- a/std/io/bufio.ts +++ b/std/io/bufio.ts @@ -426,17 +426,6 @@ abstract class AbstractBufBase { buffered(): number { return this.usedBufferBytes; } - - checkBytesWritten(numBytesWritten: number): void { - if (numBytesWritten < this.usedBufferBytes) { - if (numBytesWritten > 0) { - this.buf.copyWithin(0, numBytesWritten, this.usedBufferBytes); - this.usedBufferBytes -= numBytesWritten; - } - this.err = new Error("Short write"); - throw this.err; - } - } } /** BufWriter implements buffering for an deno.Writer object. @@ -474,9 +463,9 @@ export class BufWriter extends AbstractBufBase implements Writer { if (this.err !== null) throw this.err; if (this.usedBufferBytes === 0) return; - let numBytesWritten = 0; try { - numBytesWritten = await this.writer.write( + await Deno.writeAll( + this.writer, this.buf.subarray(0, this.usedBufferBytes) ); } catch (e) { @@ -484,8 +473,6 @@ export class BufWriter extends AbstractBufBase implements Writer { throw e; } - this.checkBytesWritten(numBytesWritten); - this.buf = new Uint8Array(this.buf.length); this.usedBufferBytes = 0; } @@ -569,9 +556,9 @@ export class BufWriterSync extends AbstractBufBase implements WriterSync { if (this.err !== null) throw this.err; if (this.usedBufferBytes === 0) return; - let numBytesWritten = 0; try { - numBytesWritten = this.writer.writeSync( + Deno.writeAllSync( + this.writer, this.buf.subarray(0, this.usedBufferBytes) ); } catch (e) { @@ -579,8 +566,6 @@ export class BufWriterSync extends AbstractBufBase implements WriterSync { throw e; } - this.checkBytesWritten(numBytesWritten); - this.buf = new Uint8Array(this.buf.length); this.usedBufferBytes = 0; } |