dankogai / js-combinatorics

power set, combination, permutation and more in JavaScript
MIT License
742 stars 97 forks source link

Is there a "hasNext" predicate? #5

Closed erelsgl closed 6 years ago

erelsgl commented 10 years ago

According to the documentation, the generators have a "next" function that returns "undefined" if there are no more elements. But, there is no way to check whether there are more elements, without consuming the next element.

Is it possible to add a boolean "hasNext" function (similar to the function with that name in Java) that returns "true" if there are more elements, but does not remove an element from the list?