mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Remove min and max modules.
This commit is contained in:
39
max.js
39
max.js
@@ -1,39 +0,0 @@
|
|||||||
import isSymbol from './isSymbol.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes the maximum value of `array`. If `array` is empty or falsey,
|
|
||||||
* `undefined` is returned.
|
|
||||||
*
|
|
||||||
* @since 0.1.0
|
|
||||||
* @category Math
|
|
||||||
* @param {Array} array The array to iterate over.
|
|
||||||
* @returns {*} Returns the maximum value.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* max([4, 2, 8, 6]);
|
|
||||||
* // => 8
|
|
||||||
*
|
|
||||||
* max([]);
|
|
||||||
* // => undefined
|
|
||||||
*/
|
|
||||||
function max(array) {
|
|
||||||
let result;
|
|
||||||
let index = -1;
|
|
||||||
const length = array ? array.length : 0;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
let computed;
|
|
||||||
const value = array[index];
|
|
||||||
|
|
||||||
if (value != null && (computed === undefined
|
|
||||||
? (value === value && !isSymbol(value))
|
|
||||||
: (value > computed)
|
|
||||||
)) {
|
|
||||||
computed = value;
|
|
||||||
result = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default max;
|
|
||||||
39
min.js
39
min.js
@@ -1,39 +0,0 @@
|
|||||||
import isSymbol from './isSymbol.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes the minimum value of `array`. If `array` is empty or falsey,
|
|
||||||
* `undefined` is returned.
|
|
||||||
*
|
|
||||||
* @since 0.1.0
|
|
||||||
* @category Math
|
|
||||||
* @param {Array} array The array to iterate over.
|
|
||||||
* @returns {*} Returns the minimum value.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* min([4, 2, 8, 6]);
|
|
||||||
* // => 2
|
|
||||||
*
|
|
||||||
* min([]);
|
|
||||||
* // => undefined
|
|
||||||
*/
|
|
||||||
function min(array) {
|
|
||||||
let result;
|
|
||||||
let index = -1;
|
|
||||||
const length = array ? array.length : 0;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
let computed;
|
|
||||||
const value = array[index];
|
|
||||||
|
|
||||||
if (value != null && (computed === undefined
|
|
||||||
? (value === value && !isSymbol(value))
|
|
||||||
: (value < computed)
|
|
||||||
)) {
|
|
||||||
computed = value;
|
|
||||||
result = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default min;
|
|
||||||
Reference in New Issue
Block a user