feat: probably fix jubeat 1dp stuff

This commit is contained in:
zkldi
2022-12-16 08:14:41 +00:00
parent 2117cb7cfd
commit cda29fe07d
10 changed files with 212 additions and 76 deletions
+15
View File
@@ -165,6 +165,21 @@ export function RoundToNDecimalPlaces(value: number, n: integer) {
return Number(value.toFixed(n));
}
/**
* Floor a number to N decimal places.
*
* @example `FloorToNDP(1.594, 1) -> 1.5`
* @example `FloorToNDP(1.599, 2) -> 1.59`
*
* @param number - The number to floor.
* @param dp - The amount of decimal places to floor to.
*/
export function FloorToNDP(number: number, dp: integer) {
const mul = 10 ** dp;
return Math.floor(number * mul) / mul;
}
export function OmitUndefinedKeys<T>(obj: Partial<T>): Partial<T> {
const omittedObj: Partial<T> = {};