nvie/itertools

islice does not work for infinite iterators

tgmeow opened this issue · 2 comments

The current implementation of islice gets stuck in an infinite loop when the for...of tries to reach the end of the infinite iterator.

const pred = slicePredicate(start, stop, step); for (const [i, value] of enumerate(iterable)) { if (pred(i)) { yield value; } }

nvie commented

Feel free to submit a PR with a fix, and add a test case for it. Happy to merge the fix 👍

This issue is stale because it has been open 30 days with no activity. If it remains without activity, it will be closed in 5 days