You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
961 B
37 lines
961 B
export default function(values, valueof) { |
|
var n = values.length, |
|
i = -1, |
|
value, |
|
min, |
|
max; |
|
|
|
if (valueof == null) { |
|
while (++i < n) { // Find the first comparable value. |
|
if ((value = values[i]) != null && value >= value) { |
|
min = max = value; |
|
while (++i < n) { // Compare the remaining values. |
|
if ((value = values[i]) != null) { |
|
if (min > value) min = value; |
|
if (max < value) max = value; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
else { |
|
while (++i < n) { // Find the first comparable value. |
|
if ((value = valueof(values[i], i, values)) != null && value >= value) { |
|
min = max = value; |
|
while (++i < n) { // Compare the remaining values. |
|
if ((value = valueof(values[i], i, values)) != null) { |
|
if (min > value) min = value; |
|
if (max < value) max = value; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
return [min, max]; |
|
}
|
|
|