{"version":3,"file":"index.cjs","sources":[""],"sourcesContent":["export type TGetRoundedArgs = Parameters<typeof getRounded>;\r\n\r\nexport type TGetRoundedReturn = ReturnType<typeof getRounded>;\r\n\r\n/**\r\n * Rounds a number to specific decimal places\r\n * @param {number} num Source number\r\n * @param {number} [places=2] Decimal places (0..100)\r\n * @returns {number} Rounded number\r\n * @throws {TypeError} getRounded: num must be a finite number\n * @throws {RangeError} getRounded: places must be an integer between 0 and 100\n * @example\r\n * // How to round number to 4 decimal places?\r\n * const num = 0.00025;\r\n * const rounded = getRounded(num, 4);\n * console.log(rounded); // => 0.0003\n * @example\n * // Round a calculated order total to two decimal places\n * const total = getRounded(subtotal + (subtotal * taxRate), 2);\n */\nexport const getRounded = (num: number, places: number = 2): number => {\r\n  if (!Number.isFinite(num)) {\n    throw new TypeError(\"getRounded: num must be a finite number\");\n  }\n  if (!Number.isInteger(places) || places < 0 || places > 100) {\n    throw new RangeError(\"getRounded: places must be an integer between 0 and 100\");\n  }\n\r\n  const shift = `e+${places}`;\r\n  const unshift = `e-${places}`;\r\n  return Number((Math.round(Number(String(num) + shift)) + unshift));\r\n};\r\n"],"names":["getRounded","num","places","Number","isFinite","TypeError","isInteger","RangeError","shift","unshift","Math","round","String"],"mappings":"yDAoBO,MAAMA,WAAa,CAACC,IAAaC,OAAiB,KACvD,IAAKC,OAAOC,SAASH,KACnB,MAAM,IAAII,UAAU,2CAEtB,IAAKF,OAAOG,UAAUJ,SAAWA,OAAS,GAAKA,OAAS,IACtD,MAAM,IAAIK,WAAW,2DAGvB,MAAMC,MAAQ,KAAKN,SACnB,MAAMO,QAAU,KAAKP,SACrB,OAAOC,OAAQO,KAAKC,MAAMR,OAAOS,OAAOX,KAAOO,QAAUC"}