-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Implement Iterator#zipLongest and improve zip description #349
base: master
Are you sure you want to change the base?
Conversation
e9e5b4e
to
3a76087
Compare
lib/iterator.js
Outdated
// Returns an iterator of Arrays where the i-th tuple contains | ||
// the i-th element from each of the passed iterators. | ||
// The iterator stops when the shortest input iterable is exhausted. | ||
// Signature: base, ...iterators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was written this way to specifically hide the implementation detail of having a separate argument which has the same meaning as every other
// Signature: base, ...iterators | |
// Signature: ...iterators |
lib/iterator.js
Outdated
// If the iterables are of uneven length, missing values are filled-in | ||
// with <undefined>. Iteration continues until the longest iterable | ||
// is exhausted. | ||
// Signature: base, ...iterators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Signature: base, ...iterators | |
// Signature: ...iterators |
lib/iterator.js
Outdated
// Returns an iterator of Arrays where the i-th tuple contains | ||
// the i-th element from each of the passed iterators. | ||
// The iterator stops when the shortest input iterable is exhausted. | ||
// Signature: ...iterators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the signature change when the default is correct
// Signature: ...iterators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metadoc will generate zip(iterators)
lib/iterator.js
Outdated
// If the iterables are of uneven length, missing values are filled-in | ||
// with <undefined>. Iteration continues until the longest iterable | ||
// is exhausted. | ||
// Signature: ...iterators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
// Signature: ...iterators |
// Signature: ...iterators | ||
// iterators <Array> | ||
// Returns: <Iterator> | ||
zipLongest(...iterators) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should allow specifying the value that should be used to fill with when there are no values left in one of the iterators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I couldn't devise a way to make a proper API.
3a76087
to
99b935f
Compare
Creates an iterator that aggregates elements from each of the iterators. If the iterables are of uneven length, missing values are filled-in with undefined or provided defaultValue. Iteration continues until the longest iterable is exhausted.
99b935f
to
e978d0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one nit
// | ||
// Returns an iterator of Arrays where the i-th tuple contains | ||
// the i-th element from each of the passed iterators. | ||
// The iterator stops when the shortest input iterable is exhausted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in other places where you're mentioning the iterable protocol in combination with "exhausting", you should use the iterator contract instead since iterable only requires for an object to have a function that returns an iterator, while the iterator is an actual object that has a next()
method and that can be "exhausted" by calling that method.
// The iterator stops when the shortest input iterable is exhausted. | |
// The iterator stops when the shortest input iterator is exhausted. |
npm run fmt
)npm run doc
to regenerate documentation based on comments)Unreleased
header in CHANGELOG.mdRefs: https://docs.python.org/3.0/library/itertools.html#itertools.zip_longest