summaryrefslogtreecommitdiff
path: root/std/io
diff options
context:
space:
mode:
Diffstat (limited to 'std/io')
-rw-r--r--std/io/bufio.ts1
-rw-r--r--std/io/bufio_test.ts6
-rw-r--r--std/io/iotest.ts14
-rw-r--r--std/io/ioutil_test.ts8
-rw-r--r--std/io/readers.ts6
-rw-r--r--std/io/writers.ts4
6 files changed, 20 insertions, 19 deletions
diff --git a/std/io/bufio.ts b/std/io/bufio.ts
index 12b5c2d2b..a944adfed 100644
--- a/std/io/bufio.ts
+++ b/std/io/bufio.ts
@@ -602,6 +602,7 @@ export async function* readStringDelim(
}
/** Read strings line-by-line from a Reader. */
+// eslint-disable-next-line require-await
export async function* readLines(
reader: Reader
): AsyncIterableIterator<string> {
diff --git a/std/io/bufio_test.ts b/std/io/bufio_test.ts
index d925175f1..ae38f6667 100644
--- a/std/io/bufio_test.ts
+++ b/std/io/bufio_test.ts
@@ -191,7 +191,7 @@ const testOutput = encoder.encode("0123456789abcdefghijklmnopqrstuvwxy");
class TestReader implements Reader {
constructor(private data: Uint8Array, private stride: number) {}
- async read(buf: Uint8Array): Promise<number | Deno.EOF> {
+ read(buf: Uint8Array): Promise<number | Deno.EOF> {
let nread = this.stride;
if (nread > this.data.byteLength) {
nread = this.data.byteLength;
@@ -200,11 +200,11 @@ class TestReader implements Reader {
nread = buf.byteLength;
}
if (nread === 0) {
- return Deno.EOF;
+ return Promise.resolve(Deno.EOF);
}
copyBytes(buf as Uint8Array, this.data);
this.data = this.data.subarray(nread);
- return nread;
+ return Promise.resolve(nread);
}
}
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));
}
}
diff --git a/std/io/ioutil_test.ts b/std/io/ioutil_test.ts
index 261f4def0..3d85a0fa1 100644
--- a/std/io/ioutil_test.ts
+++ b/std/io/ioutil_test.ts
@@ -17,10 +17,10 @@ class BinaryReader implements Reader {
constructor(private bytes: Uint8Array = new Uint8Array(0)) {}
- async read(p: Uint8Array): Promise<number | Deno.EOF> {
+ read(p: Uint8Array): Promise<number | Deno.EOF> {
p.set(this.bytes.subarray(this.index, p.byteLength));
this.index += p.byteLength;
- return p.byteLength;
+ return Promise.resolve(p.byteLength);
}
}
@@ -52,7 +52,7 @@ Deno.test(async function testReadLong2(): Promise<void> {
assertEquals(long, 0x12345678);
});
-Deno.test(async function testSliceLongToBytes(): Promise<void> {
+Deno.test(function testSliceLongToBytes(): void {
const arr = sliceLongToBytes(0x1234567890abcdef);
const actual = readLong(new BufReader(new BinaryReader(new Uint8Array(arr))));
const expected = readLong(
@@ -65,7 +65,7 @@ Deno.test(async function testSliceLongToBytes(): Promise<void> {
assertEquals(actual, expected);
});
-Deno.test(async function testSliceLongToBytes2(): Promise<void> {
+Deno.test(function testSliceLongToBytes2(): void {
const arr = sliceLongToBytes(0x12345678);
assertEquals(arr, [0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]);
});
diff --git a/std/io/readers.ts b/std/io/readers.ts
index 5b1bf1948..2d81e246f 100644
--- a/std/io/readers.ts
+++ b/std/io/readers.ts
@@ -9,14 +9,14 @@ export class StringReader implements Reader {
constructor(private readonly s: string) {}
- async read(p: Uint8Array): Promise<number | Deno.EOF> {
+ read(p: Uint8Array): Promise<number | Deno.EOF> {
const n = Math.min(p.byteLength, this.buf.byteLength - this.offs);
p.set(this.buf.slice(this.offs, this.offs + n));
this.offs += n;
if (n === 0) {
- return Deno.EOF;
+ return Promise.resolve(Deno.EOF);
}
- return n;
+ return Promise.resolve(n);
}
}
diff --git a/std/io/writers.ts b/std/io/writers.ts
index 722e0297f..b9a6a5e70 100644
--- a/std/io/writers.ts
+++ b/std/io/writers.ts
@@ -14,11 +14,11 @@ export class StringWriter implements Writer {
this.byteLength += c.byteLength;
}
- async write(p: Uint8Array): Promise<number> {
+ write(p: Uint8Array): Promise<number> {
this.chunks.push(p);
this.byteLength += p.byteLength;
this.cache = undefined;
- return p.byteLength;
+ return Promise.resolve(p.byteLength);
}
toString(): string {