Skip to content

Commit

Permalink
Missing iteratee call in groupBy and keyBy.
Browse files Browse the repository at this point in the history
  • Loading branch information
falsyvalues committed Feb 21, 2017
1 parent aaef6f6 commit 5baad4d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions groupBy.js
Expand Up @@ -23,6 +23,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
*/
function groupBy(collection, iteratee) {
return reduce(collection, (result, value, key) => {
key = iteratee(value)
if (hasOwnProperty.call(result, key)) {
result[key].push(value)
} else {
Expand Down
2 changes: 1 addition & 1 deletion keyBy.js
Expand Up @@ -25,7 +25,7 @@ import reduce from './reduce.js'
*/
function keyBy(collection, iteratee) {
return reduce(collection, (result, value, key) => (
baseAssignValue(result, key, value), result
baseAssignValue(result, iteratee(value), value), result

This comment has been minimized.

Copy link
@Vanuan

Vanuan Apr 8, 2017

wait, would it mean that this code would be considered incorrect?

_.keyBy({'id': 'value'}, 'id');

// iteratee is not a function

This comment has been minimized.

Copy link
@jdalton

jdalton Apr 8, 2017

Member

I'm removing shorthands by default in v5.

This comment has been minimized.

Copy link
@falsyvalues

falsyvalues Apr 10, 2017

Author Contributor

👍

), {})
}

Expand Down

0 comments on commit 5baad4d

Please sign in to comment.