Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

lundibundi
Copy link
Member

  • code is properly formatted (npm run fmt)
  • tests are added/updated
  • documentation is updated (npm run doc to regenerate documentation based on comments)
  • description of changes is added under the Unreleased header in CHANGELOG.md

lib/iterator.js Outdated Show resolved Hide resolved
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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// array. Boolean will be mapped `false` -> `0`, `true` -> `1`.
// array. Boolean will be cast to number.

lib/iterator.js Outdated
Comment on lines 200 to 202
let index;
if (typeof res !== 'number') index = res ? 1 : 0;
else index = res;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

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

Suggested change
// Consumes an iterator, partitioning it into Arrays.
// Consumes an iterator, partitioning it into Arrays

belochub pushed a commit that referenced this pull request Jul 6, 2020
@belochub
Copy link
Member

belochub commented Jul 6, 2020

Landed in 58456fa.

@belochub belochub closed this Jul 6, 2020
@belochub belochub deleted the impl-iter-partition branch July 6, 2020 10:46
lundibundi added a commit to metarhia/iterator that referenced this pull request Sep 13, 2020
lundibundi added a commit to metarhia/iterator that referenced this pull request Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants