mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 02:44:45 +00:00
15 lines
410 B
TypeScript
15 lines
410 B
TypeScript
/**
|
|
* 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);
|
|
} |