Skip to content

Commit

Permalink
refactor: rename sync io interfaces (denoland/deno#4945)
Browse files Browse the repository at this point in the history
This commit renames sync io interfaces:
* SyncReader -> ReaderSync
* SyncWriter -> WriterSync
* SyncSeeker -> SeekerSync
  • Loading branch information
bartlomieju authored Apr 28, 2020
1 parent 6312e30 commit a1cbc1a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions io/bufio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

type Reader = Deno.Reader;
type Writer = Deno.Writer;
type SyncWriter = Deno.SyncWriter;
type WriterSync = Deno.WriterSync;
import { charCode, copyBytes } from "./util.ts";
import { assert } from "../testing/asserts.ts";

Expand Down Expand Up @@ -524,25 +524,25 @@ export class BufWriter extends AbstractBufBase implements Writer {
}
}

/** BufWriterSync implements buffering for a deno.SyncWriter object.
* If an error occurs writing to a SyncWriter, no more data will be
/** BufWriterSync implements buffering for a deno.WriterSync object.
* If an error occurs writing to a WriterSync, no more data will be
* accepted and all subsequent writes, and flush(), will return the error.
* After all data has been written, the client should call the
* flush() method to guarantee all data has been forwarded to
* the underlying deno.SyncWriter.
* the underlying deno.WriterSync.
*/
export class BufWriterSync extends AbstractBufBase implements SyncWriter {
export class BufWriterSync extends AbstractBufBase implements WriterSync {
/** return new BufWriterSync unless writer is BufWriterSync */
static create(
writer: SyncWriter,
writer: WriterSync,
size: number = DEFAULT_BUF_SIZE
): BufWriterSync {
return writer instanceof BufWriterSync
? writer
: new BufWriterSync(writer, size);
}

constructor(private writer: SyncWriter, size: number = DEFAULT_BUF_SIZE) {
constructor(private writer: WriterSync, size: number = DEFAULT_BUF_SIZE) {
super();
if (size <= 0) {
size = DEFAULT_BUF_SIZE;
Expand All @@ -553,13 +553,13 @@ export class BufWriterSync extends AbstractBufBase implements SyncWriter {
/** Discards any unflushed buffered data, clears any error, and
* resets buffer to write its output to w.
*/
reset(w: SyncWriter): void {
reset(w: WriterSync): void {
this.err = null;
this.usedBufferBytes = 0;
this.writer = w;
}

/** Flush writes any buffered data to the underlying io.SyncWriter. */
/** Flush writes any buffered data to the underlying io.WriterSync. */
flush(): void {
if (this.err !== null) throw this.err;
if (this.usedBufferBytes === 0) return;
Expand Down

0 comments on commit a1cbc1a

Please sign in to comment.