Re: [whatwg/streams] ReadableStream.from(asyncIterable) (#1083)

@ricea 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

That's amazing. I feel like I can just barely understand it, but it's a stretch.

I have a slight preference for leaving it as is, on the grounds that a comment saying "we don't need to do this bit" is easier to understand than the actual implementation. But on the other hand, we do try to keep as close to the standard text as possible, so it could go either way. I will let @domenic cast the deciding vote on this one.

-- 
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_r526331112

Received on Wednesday, 18 November 2020 18:38:06 UTC