mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
34
.internal/baseExtremum.js
Normal file
34
.internal/baseExtremum.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import isSymbol from './isSymbol.js';
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `max` and `min` which accepts a
|
||||
* `comparator` to determine the extremum value.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} iteratee The iteratee invoked per iteration.
|
||||
* @param {Function} comparator The comparator used to compare values.
|
||||
* @returns {*} Returns the extremum value.
|
||||
*/
|
||||
function baseExtremum(array, iteratee, comparator) {
|
||||
let result;
|
||||
let index = -1;
|
||||
const length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
let computed;
|
||||
const value = array[index];
|
||||
const current = iteratee(value);
|
||||
|
||||
if (current != null && (computed === undefined
|
||||
? (current === current && !isSymbol(current))
|
||||
: comparator(current, computed)
|
||||
)) {
|
||||
computed = current;
|
||||
result = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default baseExtremum;
|
||||
Reference in New Issue
Block a user