-
Notifications
You must be signed in to change notification settings - Fork 34
What happens if you pass a sync iterator (not iterable) to AsyncIterator.from? #237
Comments
we should assume its an async iterator, because you called |
I feel like it's not totally unreasonable to call |
at the risk of sounding like a shitpost, |
That does happen to work, but only because |
I had absolutely expected |
The primary purpose of |
Also of note: if the iterator has a |
I am tempted to resolve this by saying the |
I've updated #233 to address this. It aligns
|
If you have an object
{ next() {...} }
, and it doesn't have aSymbol.iterator
orSymbol.asyncIterator
method, there's no way to tell if that's sync or async.If you pass such a thing to
AsyncIterator.from
, the result is supposed to be an async iterator. Right now, any time a sync iterable is passed to something which expects an async iterable, and that sync iterator yields Promises, the spec will lift fromIterator<Promise<T>>
toAsyncIterator<T>
, byawait
ing the.value
property (in%AsyncFromSyncIteratorPrototype%.next
).But here there's no way to tell if the passed thing is sync or async. So should values from the
.value
property be awaited or not?That is:
The text was updated successfully, but these errors were encountered: