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

_.partition: include index and and array arguments in the predicate #1593

Merged
merged 3 commits into from
Apr 23, 2014
Merged

Conversation

coolov
Copy link
Contributor

@coolov coolov commented Apr 19, 2014

Includes the index and a reference to the array in the arguments of the predicate. This allows for more ways to partition the data. One example is by odd and even array indices.

@@ -454,7 +454,7 @@
predicate = lookupIterator(predicate, context);
var pass = [], fail = [];
_.each(obj, function(elem) {
(predicate(elem) ? pass : fail).push(elem);
(predicate.apply(null, arguments) ? pass : fail).push(elem);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Throughout the library we usually write this predicate(value, index, list)

@jdalton
Copy link
Contributor

jdalton commented Apr 19, 2014

This PR could be trumped by #1594

@coolov coolov changed the title _.partition: include iterator and context arguments in the predicate _.partition: include index and and array arguments in the predicate Apr 22, 2014
@braddunbar braddunbar merged commit 1b0e8a3 into jashkenas:master Apr 23, 2014
@braddunbar
Copy link
Collaborator

Merged above and tweaked a bit in af62a21.

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.

5 participants