1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 10:54:44 +00:00

feat(packages/stdlib): add bigint math utils

This commit is contained in:
2024-09-30 06:20:09 +07:00
parent 061d45f6fd
commit 975ca98f9a
11 changed files with 333 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
/**
* Like `Math.max` but for BigInts
*
* @param {...bigint} values The values to compare
* @returns {bigint} The largest value
* @throws {TypeError} If no arguments are provided
*
* @since 0.0.2
*/
export function maxBigInt(...values: bigint[]) {
if (!values.length)
throw new TypeError('maxBigInt requires at least one argument');
return values.reduce((acc, val) => val > acc ? val : acc);
}