itertools icon indicating copy to clipboard operation
itertools copied to clipboard

Operating on async-iterables

Open jbriales opened this issue 2 years ago • 1 comments

It seems the helpers in this package do not work when run on async-iterables. E.g. the following will complain about missing iterable[Symbol.iterator]?

Uncaught TypeError: iterable[Symbol.iterator] is not a function

Is the lack for support for async-iterables a known issue? Maybe the documentation should state this?

Also, is this just a matter of extending the logic to deal with the specifics of the async-iterables vs normal iterables? Or is there a deeper constraint/issue here preventing support for those?

jbriales avatar Dec 04 '22 15:12 jbriales

Is the lack for support for async-iterables a known issue?

Yes, it's a known thing, unfortunately. In JavaScript, a sync and async iterator are different beasts, and you need to write a different version of the async one. (Much like you cannot fix and match sync/async functions in JS.)

Or is there a deeper constraint/issue here preventing support for those?

This library just doesn't support async iterables right now, but it could if support for them was added. It would basically mean that all the existing functions would have to be duplicated, and perhaps exposed as asyncMap, asyncFilter, etc.

nvie avatar Feb 06 '23 08:02 nvie