@@ -6,11 +6,8 @@ import find from './find.js';
66// `true` if its first argument is more extreme than (i.e., should be preferred
77// over) its second argument, `false` otherwise. `iteratee` and `context`, like
88// in other collection functions, let you map the actual values in `collection`
9- // to the values to `compare`. `decide` is an optional customization point
10- // which is only present for historical reasons; please don't use it, as it will
11- // likely be removed in the future.
9+ // to the values to `compare`.
1210export default function extremum ( collection , compare , iteratee , context , decide ) {
13- decide || ( decide = identity ) ;
1411 // `extremum` is essentially a combined map+reduce with **two** accumulators:
1512 // `result` and `iterResult`, respectively the unmapped and the mapped version
1613 // corresponding to the same element.
@@ -25,9 +22,12 @@ export default function extremum(collection, compare, iteratee, context, decide)
2522 first = false ;
2623 }
2724 } ) ;
28- // `extremum` normally returns an unmapped element from `collection`. However,
29- // `_.min` and `_.max` forcibly return a number even if there is no element
30- // that maps to a numeric value. Passing both accumulators through `decide`
31- // before returning enables this behavior.
32- return decide ( result , iterResult ) ;
25+ // `extremum` would normally return `result`. However, `_.min` and `_.max`
26+ // forcibly return a number even if there is no element that maps to a numeric
27+ // value. Passing both accumulators through `decide` before returning enables
28+ // this behavior.
29+ // `decide` is an optional customization point which is only present for the
30+ // above historical reason; please don't use it, as it will likely be removed
31+ // in the future.
32+ return ( decide || identity ) ( result , iterResult ) ;
3333}
0 commit comments