-
-
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#partition() to partition it into arrays #339
Conversation
lib/iterator.js
Outdated
// value <any> current iterator element. | ||
// Returns: <boolean> | <number> key denoting resulting partition this | ||
// value will be assigned to. Number denotes index in the resulting | ||
// array. Boolean will be mapped `false` -> `0`, `true` -> `1`. |
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.
// array. Boolean will be mapped `false` -> `0`, `true` -> `1`. | |
// array. Boolean will be cast to number. |
lib/iterator.js
Outdated
let index; | ||
if (typeof res !== 'number') index = res ? 1 : 0; | ||
else index = res; |
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.
let index; | |
if (typeof res !== 'number') index = res ? 1 : 0; | |
else index = res; | |
const index = typeof res === 'boolean' ? Number(res) : res; |
lib/iterator.js
Outdated
@@ -183,6 +183,33 @@ class Iterator { | |||
return new SkipWhileIterator(this, predicate, thisArg); | |||
} | |||
|
|||
// Consumes an iterator, partitioning it into Arrays. |
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.
Same as for the previous PR, remove the dots
// Consumes an iterator, partitioning it into Arrays. | |
// Consumes an iterator, partitioning it into Arrays |
4ca0ac4
to
083b92d
Compare
083b92d
to
1f9b7ff
Compare
Landed in 58456fa. |
npm run fmt
)npm run doc
to regenerate documentation based on comments)Unreleased
header in CHANGELOG.md