Get items appearing on the sheet, still a lot to do but this is a strong step in the right direction

This commit is contained in:
Oliver 2026-03-15 22:37:55 -06:00
parent 6b03d62234
commit 23a402f11a
9 changed files with 254 additions and 10 deletions

View file

@ -0,0 +1,20 @@
/**
* Takes a possibly-decimal value and rounds after a certain precision, keeping
* only the specified amount of decimals.
*
* @param {number} value The value that is to be rounded.
* @param {number} precision The number of decimal places to round to. Must be a
* positive integer.
* @returns The rounded number
*/
export function toPrecision(value, precision = 1) {
if (!Number.isInteger(precision)) {
throw `Precision must be an integer`;
};
if (precision < 0) {
throw `Precision must be greater than or equal to 0`;
};
const m = 10 ** precision;
return Math.round(value * m) / m;
};