main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
895 bytes
|
Line | |
---|
1 | import isSymbol from './isSymbol.js';
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * The base implementation of methods like `_.max` and `_.min` which accepts a
|
---|
5 | * `comparator` to determine the extremum value.
|
---|
6 | *
|
---|
7 | * @private
|
---|
8 | * @param {Array} array The array to iterate over.
|
---|
9 | * @param {Function} iteratee The iteratee invoked per iteration.
|
---|
10 | * @param {Function} comparator The comparator used to compare values.
|
---|
11 | * @returns {*} Returns the extremum value.
|
---|
12 | */
|
---|
13 | function baseExtremum(array, iteratee, comparator) {
|
---|
14 | var index = -1,
|
---|
15 | length = array.length;
|
---|
16 |
|
---|
17 | while (++index < length) {
|
---|
18 | var value = array[index],
|
---|
19 | current = iteratee(value);
|
---|
20 |
|
---|
21 | if (current != null && (computed === undefined
|
---|
22 | ? (current === current && !isSymbol(current))
|
---|
23 | : comparator(current, computed)
|
---|
24 | )) {
|
---|
25 | var computed = current,
|
---|
26 | result = value;
|
---|
27 | }
|
---|
28 | }
|
---|
29 | return result;
|
---|
30 | }
|
---|
31 |
|
---|
32 | export default baseExtremum;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.