diff options
author | Samrith Shankar <samrith-s@users.noreply.github.com> | 2020-03-20 14:38:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-20 09:38:34 -0400 |
commit | 798904b0f2ed0c7284b67bba2f125f406b5850de (patch) | |
tree | 5aba8d35aa8984aa778c894258bcaed56f1ce17c /std/io/iotest.ts | |
parent | 35f6e2e45ddb96524a6bdf54b0a6155caa88d5e0 (diff) |
Add require-await lint rule (#4401)
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)); } } |