diff options
Diffstat (limited to 'std/io/iotest.ts')
-rw-r--r-- | std/io/iotest.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/std/io/iotest.ts b/std/io/iotest.ts index 1e922e33f..e2cf315aa 100644 --- a/std/io/iotest.ts +++ b/std/io/iotest.ts @@ -10,14 +10,14 @@ type Reader = Deno.Reader; export class OneByteReader implements Reader { constructor(readonly r: Reader) {} - async read(p: Uint8Array): Promise<number | Deno.EOF> { + read(p: Uint8Array): Promise<number | Deno.EOF> { if (p.byteLength === 0) { - return 0; + return Promise.resolve(0); } if (!(p instanceof Uint8Array)) { throw Error("expected Uint8Array"); } - return this.r.read(p.subarray(0, 1)); + return Promise.resolve(this.r.read(p.subarray(0, 1))); } } @@ -27,12 +27,12 @@ export class OneByteReader implements Reader { export class HalfReader implements Reader { constructor(readonly r: Reader) {} - async read(p: Uint8Array): Promise<number | Deno.EOF> { + read(p: Uint8Array): Promise<number | Deno.EOF> { if (!(p instanceof Uint8Array)) { throw Error("expected Uint8Array"); } const half = Math.floor((p.byteLength + 1) / 2); - return this.r.read(p.subarray(0, half)); + return Promise.resolve(this.r.read(p.subarray(0, half))); } } @@ -43,11 +43,11 @@ export class TimeoutReader implements Reader { count = 0; constructor(readonly r: Reader) {} - async read(p: Uint8Array): Promise<number | Deno.EOF> { + read(p: Uint8Array): Promise<number | Deno.EOF> { this.count++; if (this.count === 2) { throw new Deno.errors.TimedOut(); } - return this.r.read(p); + return Promise.resolve(this.r.read(p)); } } |