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:
15
packages/stdlib/src/math/bigint/maxBigInt/index.ts
Normal file
15
packages/stdlib/src/math/bigint/maxBigInt/index.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user