You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To describe the bug by way of an example, I am using the Repeater library which contains a class, Repeater. Repeater is not a subclass of AsyncIterator, but it is iterator-like in a way that is duck-type compatible with iterators and can be for async ...'d and etc. However, Repeater does not implement the iterator helpers since it is an implementation of an ECMAScript iterator and without the stage3 helpers.
When I do AsyncIterator.from(...) on a Repeater to then be able to use the iterator helpers on the resulting iterator, I get:
Argument of type 'Repeater<ElementType, any, unknown>' is not assignable to parameter of type '_AsyncIteratorLike<ElementType, any, undefined>'.
Type 'Repeater<ElementType, any, unknown>' is missing the following properties from type 'AsyncIterator<ElementType, any, undefined>': map, filter, asIndexedPairs, take, and 43 more.ts(2345)
This is because the typing for AsyncIterator expects an iterator "enhanced" by this polyfill. I suggest making an AsyncIteratorLike and IteratorLike that include only the bare minimum items to support AsyncIterator.from and Iterator.from respectively, which would include only the original ES mainline characteristics.
The text was updated successfully, but these errors were encountered:
Improves typing & spec compliance
fixes: [Bug] Typing issue causes AsyncIterator.from(...) to fail against plain ES iterator-like things #21
fixes: [Bug] counter/index argument is not provided to callback functions #22
This has been fixed in version 3.0.0. Thank you for reporting this bug!
This was an oversight from me and I have fixed this not only in (Async)Iterator.from, but in other methods as well, like .flatMap, .flatten, .zip, and others.
I have made one dumb mistake not defining in iterable-likes Symbol.iterator as a function but as a regular property.
So please update to 3.0.1.
I am sorry for this.
To describe the bug by way of an example, I am using the Repeater library which contains a class,
Repeater
.Repeater
is not a subclass ofAsyncIterator
, but it is iterator-like in a way that is duck-type compatible with iterators and can befor async ...
'd and etc. However,Repeater
does not implement the iterator helpers since it is an implementation of an ECMAScript iterator and without the stage3 helpers.When I do
AsyncIterator.from(...)
on aRepeater
to then be able to use the iterator helpers on the resulting iterator, I get:This is because the typing for AsyncIterator expects an iterator "enhanced" by this polyfill. I suggest making an
AsyncIteratorLike
andIteratorLike
that include only the bare minimum items to supportAsyncIterator.from
andIterator.from
respectively, which would include only the original ES mainline characteristics.The text was updated successfully, but these errors were encountered: