main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
989 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import baseExtremum from './_baseExtremum.js';
|
---|
| 2 | import baseIteratee from './_baseIteratee.js';
|
---|
| 3 | import baseLt from './_baseLt.js';
|
---|
| 4 |
|
---|
| 5 | /**
|
---|
| 6 | * This method is like `_.min` except that it accepts `iteratee` which is
|
---|
| 7 | * invoked for each element in `array` to generate the criterion by which
|
---|
| 8 | * the value is ranked. The iteratee is invoked with one argument: (value).
|
---|
| 9 | *
|
---|
| 10 | * @static
|
---|
| 11 | * @memberOf _
|
---|
| 12 | * @since 4.0.0
|
---|
| 13 | * @category Math
|
---|
| 14 | * @param {Array} array The array to iterate over.
|
---|
| 15 | * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
---|
| 16 | * @returns {*} Returns the minimum value.
|
---|
| 17 | * @example
|
---|
| 18 | *
|
---|
| 19 | * var objects = [{ 'n': 1 }, { 'n': 2 }];
|
---|
| 20 | *
|
---|
| 21 | * _.minBy(objects, function(o) { return o.n; });
|
---|
| 22 | * // => { 'n': 1 }
|
---|
| 23 | *
|
---|
| 24 | * // The `_.property` iteratee shorthand.
|
---|
| 25 | * _.minBy(objects, 'n');
|
---|
| 26 | * // => { 'n': 1 }
|
---|
| 27 | */
|
---|
| 28 | function minBy(array, iteratee) {
|
---|
| 29 | return (array && array.length)
|
---|
| 30 | ? baseExtremum(array, baseIteratee(iteratee, 2), baseLt)
|
---|
| 31 | : undefined;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | export default minBy;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.