- From: Mattias Buelens <notifications@github.com>
- Date: Tue, 29 Dec 2020 09:19:16 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 29 December 2020 17:19:29 UTC
@MattiasBuelens 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 I added a test for the general case of [a sync iterable of promises](https://github.com/web-platform-tests/wpt/blob/9ce2d37efeb10b9b6b8df22ddd0ca33b0af936a7/streams/readable-streams/from.any.js#L52-L64), and the specific case of [an array of promises](https://github.com/web-platform-tests/wpt/blob/9ce2d37efeb10b9b6b8df22ddd0ca33b0af936a7/streams/readable-streams/from.any.js#L9-L14). These tests require a correct implementation of `CreateAsyncFromSyncIterator`, so I added the above snippet (with extra comments) to the reference implementation. 🙂 -- 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_r549784091
Received on Tuesday, 29 December 2020 17:19:29 UTC