- From: Domenic Denicola <notifications@github.com>
- Date: Thu, 19 Nov 2020 14:07:33 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 19 November 2020 22:07:45 UTC
@domenic commented on this pull request. > + } + if (typeof func !== 'function') { + throw new TypeError(); + } + return func; +}; + +exports.GetIterator = (obj, hint = 'sync', method) => { + assert(hint === 'sync' || hint === 'async'); + if (method === undefined) { + if (hint === 'async') { + method = exports.GetMethod(obj, Symbol.asyncIterator); + if (method === undefined) { + const syncMethod = exports.GetMethod(obj, Symbol.iterator); + const syncIterator = exports.GetIterator(obj, 'sync', syncMethod); + return syncIterator; // TODO sync to async iterator No, wait. The issue is what happens if you have a sync iterator of promises. With AsyncFromSyncIterator, you get the promises unwrapped. Without it, you get the promises. So I think omitting this step would break test cases like `ReadableStream.from([promiseFor1, promiseFor2])`. That should be equivalent to `ReadableStream.from([1, 2])` but without the AsyncFromSyncIterator, it would give you a stream where `(await reader.read()).value` was a promise. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/pull/1083#discussion_r527234395
Received on Thursday, 19 November 2020 22:07:45 UTC