-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toIterable() fails with completed iterators #204
Comments
It may be argued that The proper syntax goes like this: But let's look at how interface IteratorYieldResult<TYield> {
done?: false;
value: TYield;
}
interface IteratorReturnResult<TReturn> {
done: true;
value: TReturn;
}
type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>; So we can see that @RebeccaStevens What do you think? If you agree, please make the change 😉 |
@RebeccaStevens b.t.w., you have this comment inside Perhaps hasOwnProperty is usable for this? ;) The difference from
But our |
I deicide it is best to go back to using the |
v2.8.0-beta.2 now contains the fix. I'm gonna play a little with the new concurrencyFork operator within iter-ops-extras, to make sure it is as every bit as good as I was expecting, and then will make a proper 2.8.0 release 😉 @RebeccaStevens Never got your view on the new |
It looks good. I'll have a more in-depth look at it a bit later. |
The fix for this was released in v2.8.0. @RebeccaStevens I tested it out ( |
Verified fix in 2.8.0. Thanks! |
I have a case where I need to wrap a possibly-completed iterator as an iterator to pipe() through some other things. I know the result will be an empty iterator, but I don't have a way to test for this before building the pipe() chain.
In debugging, I found that toIterable() calls a typeguard function isIteratorResult:
iter-ops/src/typeguards.ts
Line 91 in 35bc52e
isIteratorResult
tests forvalue
, but a completed iterator does not return a value. It does returndone
in all cases:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#iterators
The fix is to look for a
done
property instead of avalue
property.The text was updated successfully, but these errors were encountered: