fui-material 2.2.10 → 2.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50163,29 +50163,33 @@ function fDownloadBlobFile(blob, fileName) {
50163
50163
  document.body.removeChild(link2);
50164
50164
  window.URL.revokeObjectURL(url);
50165
50165
  }
50166
- function fBankRound(value, decimalPlaces) {
50167
- if (decimalPlaces == void 0) decimalPlaces = 2;
50168
- const factor = Math.pow(10, decimalPlaces);
50169
- const roundedValue = Math.round(value * factor) / factor;
50170
- const strValue = roundedValue.toString();
50171
- const dotIndex = strValue.indexOf(".");
50172
- if (dotIndex === -1) {
50173
- return roundedValue;
50174
- }
50175
- const fractionalPart = strValue.slice(dotIndex + 1);
50176
- if (fractionalPart.length <= decimalPlaces) {
50177
- return roundedValue;
50178
- }
50179
- const nextDigit = fractionalPart[decimalPlaces];
50180
- if (nextDigit === "5") {
50181
- const lastDigit = fractionalPart[decimalPlaces - 1];
50182
- if (+lastDigit % 2 !== 0) {
50183
- return +(roundedValue + Math.pow(10, -decimalPlaces)).toFixed(decimalPlaces);
50166
+ function fBankRound(value, decimals = 2) {
50167
+ const str = typeof value === "number" ? value.toString() : value;
50168
+ if (!/^[-+]?\d+(\.\d+)?$/.test(str)) throw new Error("Некорректное число");
50169
+ const [intPart, fracPart = ""] = str.split(".");
50170
+ if (decimals < 0) throw new Error("Количество знаков не может быть отрицательным");
50171
+ if (fracPart.length <= decimals) return Number(value);
50172
+ const roundingDigit = Number(fracPart[decimals]);
50173
+ const rest = fracPart.slice(decimals + 1);
50174
+ const fractionToKeep = fracPart.slice(0, decimals);
50175
+ const sign = intPart.startsWith("-") ? -1 : 1;
50176
+ const absInt = BigInt(intPart.replace("-", ""));
50177
+ const hasNonZeroAfter = /[1-9]/.test(rest);
50178
+ let resultFrac = fractionToKeep;
50179
+ let carry = 0;
50180
+ if (roundingDigit > 5 || roundingDigit === 5 && (hasNonZeroAfter || Number(fractionToKeep[decimals - 1] ?? 0) % 2 !== 0)) {
50181
+ const num = BigInt(resultFrac || "0") + BigInt(1);
50182
+ const max = BigInt(10) ** BigInt(decimals);
50183
+ if (num >= max) {
50184
+ carry = 1;
50185
+ resultFrac = "0".repeat(decimals);
50184
50186
  } else {
50185
- return +roundedValue.toFixed(decimalPlaces);
50187
+ resultFrac = num.toString().padStart(decimals, "0");
50186
50188
  }
50187
50189
  }
50188
- return +roundedValue.toFixed(decimalPlaces);
50190
+ const resultInt = absInt + BigInt(carry);
50191
+ const result2 = (sign < 0 ? "-" : "") + resultInt.toString() + (decimals > 0 ? "." + resultFrac.padEnd(decimals, "0") : "");
50192
+ return Number(result2);
50189
50193
  }
50190
50194
  const fFormatRuNumber = (a, options) => {
50191
50195
  if (typeof a !== "number" || isNaN(a)) return (options == null ? void 0 : options.returnNumber) ? NaN : "";