diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2019-07-06 23:16:03 +0900 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-07-06 10:16:03 -0400 |
commit | a948f9ff541e5983bc29113d1e0f1898206f8581 (patch) | |
tree | 67e47efd88468886a8e2a50ad28cc2c75be69389 /js/files_test.ts | |
parent | 33cb79d24cf03c2c771dfa499e4cc8ee7bcee800 (diff) |
io: change Reader interface (#2591)
Instead of returning { nread: number, eof: bool }, read() returns EOF | number.
Diffstat (limited to 'js/files_test.ts')
-rw-r--r-- | js/files_test.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/js/files_test.ts b/js/files_test.ts index 350c1eb41..babec1fc2 100644 --- a/js/files_test.ts +++ b/js/files_test.ts @@ -39,15 +39,16 @@ test(async function readerToAsyncIterator(): Promise<void> { constructor(private readonly s: string) {} - async read(p: Uint8Array): Promise<Deno.ReadResult> { + async read(p: Uint8Array): Promise<number | Deno.EOF> { const n = Math.min(p.byteLength, this.buf.byteLength - this.offset); p.set(this.buf.slice(this.offset, this.offset + n)); this.offset += n; - return { - nread: n, - eof: this.offset === this.buf.byteLength - }; + if (n === 0) { + return Deno.EOF; + } + + return n; } } @@ -228,7 +229,7 @@ testPerm( const buf = new Uint8Array(20); await file.seek(0, Deno.SeekMode.SEEK_START); const result = await file.read(buf); - assertEquals(result.nread, 13); + assertEquals(result, 13); file.close(); await Deno.remove(tempDir, { recursive: true }); |