Files
openzeppelin-contracts/test/helpers/math.js
Hadrien Croubois cffb2f1ddc Migrate math tests to ethers.js v6 (#4769)
Co-authored-by: Ernesto García <ernestognw@gmail.com>
2023-12-04 13:00:00 -06:00

14 lines
503 B
JavaScript

// Array of number or bigint
const max = (...values) => values.slice(1).reduce((x, y) => (x > y ? x : y), values.at(0));
const min = (...values) => values.slice(1).reduce((x, y) => (x < y ? x : y), values.at(0));
const sum = (...values) => values.slice(1).reduce((x, y) => x + y, values.at(0));
module.exports = {
// re-export min, max & sum of integer / bignumber
min,
max,
sum,
// deprecated: BN version of sum
BNsum: (...args) => args.slice(1).reduce((x, y) => x.add(y), args.at(0)),
};