rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
24 lines • 693 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.arrayMax = void 0;
const _debug_js_1 = require("../../debug/_debug.js");
/**
* @public
* Find the largest number in an array, if the array is empty the return is -Infinity.
*
* @remarks
* See {@link arrayMax}.
*/
function arrayMax(numbers) {
let max = -Infinity;
for (let i = 0, iEnd = numbers.length; i < iEnd; ++i) {
const value = numbers[i];
_BUILD.DEBUG && _debug_js_1._Debug.assert(value === value, "NaN not supported");
if (value > max) {
max = value;
}
}
return max;
}
exports.arrayMax = arrayMax;
//# sourceMappingURL=array-max.js.map