@papb/json-excel
Version:
Create a pretty Excel table from JSON data with a very simple API
24 lines • 793 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.clamp = exports.getSum = exports.getMax = void 0;
function getMax(numbers) {
// We do not use Math.max(...numbers) because JavaScript
// functions have an argument limit of about 30k, we don't
// want it to crash for large arrays
let max = -Infinity;
for (const number of numbers) {
max = Math.max(max, number);
}
return max;
}
exports.getMax = getMax;
function getSum(numbers) {
// eslint-disable-next-line unicorn/no-array-reduce
return numbers.reduce((a, b) => a + b, 0);
}
exports.getSum = getSum;
function clamp(value, min, max) {
return value < min ? min : (value > max ? max : value);
}
exports.clamp = clamp;
//# sourceMappingURL=numeric-helpers.js.map