diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2018-10-31 15:29:13 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-31 07:29:13 -0700 |
commit | 162eeca3734cd88b311150bcaa3f97e120b91f29 (patch) | |
tree | 3d4e8fb2d5d46499260ca8b91361301293d7b47c /js/files_test.ts | |
parent | 669b1a4e97793786b579e8bd5def940359c2536d (diff) |
Add helper to turn deno.Reader into async iterator (#1130)
Diffstat (limited to 'js/files_test.ts')
-rw-r--r-- | js/files_test.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/js/files_test.ts b/js/files_test.ts index 9759e0b26..37f63d9fa 100644 --- a/js/files_test.ts +++ b/js/files_test.ts @@ -17,3 +17,15 @@ test(async function filesCopyToStdout() { assertEqual(bytesWritten, fileSize); console.log("bytes written", bytesWritten); }); + +test(async function filesToAsyncIterator() { + const filename = "tests/hello.txt"; + const file = await deno.open(filename); + + let totalSize = 0; + for await (const buf of deno.toAsyncIterator(file)) { + totalSize += buf.byteLength; + } + + assertEqual(totalSize, 12); +}); |