diff options
Diffstat (limited to 'ext/web')
-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; } } |