mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 14:41:35 +00:00
infinity checks on bigint
This commit is contained in:
@@ -308,6 +308,12 @@ export function generateID(): GameID {
|
||||
}
|
||||
|
||||
export function toInt(num: number): bigint {
|
||||
if (num === Infinity) {
|
||||
return BigInt(Number.MAX_SAFE_INTEGER);
|
||||
}
|
||||
if (num === -Infinity) {
|
||||
return BigInt(Number.MIN_SAFE_INTEGER);
|
||||
}
|
||||
return BigInt(Math.floor(num));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user