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 | |
| parent | d5634164cb86771fc279468cbb93e311c1ad3089 (diff) | |
fix(core): Add `Generator` and `AsyncGenerator` to promordials (#17241)
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/web/06_streams.js | 5 | ||||
| -rw-r--r-- | ext/web/09_file.js | 16 |
2 files changed, 13 insertions, 8 deletions
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 22baa1234..5b1c0141d 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -19,6 +19,7 @@ ArrayPrototypeMap, ArrayPrototypePush, ArrayPrototypeShift, + AsyncGeneratorPrototype, BigInt64ArrayPrototype, BigUint64ArrayPrototype, DataView, @@ -4439,9 +4440,7 @@ } /** @type {AsyncIterator<unknown, unknown>} */ - const asyncIteratorPrototype = ObjectGetPrototypeOf( - ObjectGetPrototypeOf(async function* () {}).prototype, - ); + const asyncIteratorPrototype = ObjectGetPrototypeOf(AsyncGeneratorPrototype); const _iteratorNext = Symbol("[[iteratorNext]]"); const _iteratorFinished = Symbol("[[iteratorFinished]]"); 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; } } |
