diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-01-15 13:26:05 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-15 04:26:05 +0000 |
commit | 1dc3609ff22e6a7be4d86d2ba983f81dfd8c1fd4 (patch) | |
tree | 7521bbcca4298a492480dd291e91a5e06cd9c4a0 /ext/web/09_file.js | |
parent | d5634164cb86771fc279468cbb93e311c1ad3089 (diff) |
fix(core): Add `Generator` and `AsyncGenerator` to promordials (#17241)
Diffstat (limited to 'ext/web/09_file.js')
-rw-r--r-- | ext/web/09_file.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/web/09_file.js b/ext/web/09_file.js index f789a24d2..0fc1e7e96 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -20,6 +20,7 @@ ArrayBufferPrototypeSlice, ArrayBufferIsView, ArrayPrototypePush, + AsyncGeneratorPrototypeNext, Date, DatePrototypeGetTime, MathMax, @@ -330,7 +331,9 @@ /** @param {ReadableByteStreamController} controller */ async pull(controller) { while (true) { - const { value, done } = await partIterator.next(); + const { value, done } = await AsyncGeneratorPrototypeNext( + partIterator, + ); if (done) return controller.close(); if (value.byteLength > 0) { return controller.enqueue(value); @@ -354,11 +357,14 @@ const bytes = new Uint8Array(size); const partIterator = toIterator(this[_parts]); let offset = 0; - // deno-lint-ignore prefer-primordials - for await (const chunk of partIterator) { - const byteLength = chunk.byteLength; + while (true) { + const { value, done } = await AsyncGeneratorPrototypeNext( + partIterator, + ); + if (done) break; + const byteLength = value.byteLength; if (byteLength > 0) { - TypedArrayPrototypeSet(bytes, chunk, offset); + TypedArrayPrototypeSet(bytes, value, offset); offset += byteLength; } } |