fui-material 2.2.13 → 2.2.15

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.
@@ -50094,32 +50094,55 @@ function fDownloadBlobFile(blob, fileName) {
50094
50094
  window.URL.revokeObjectURL(url);
50095
50095
  }
50096
50096
  function fBankRound(value, decimals = 2) {
50097
- const str = typeof value === "number" ? value.toString() : value;
50098
- if (!/^[-+]?\d+(\.\d+)?$/.test(str)) throw new Error("Некорректное число");
50099
- const [intPart, fracPart = ""] = str.split(".");
50100
- if (decimals < 0) throw new Error("Количество знаков не может быть отрицательным");
50101
- if (fracPart.length <= decimals) return Number(value);
50102
- const roundingDigit = Number(fracPart[decimals]);
50103
- const rest = fracPart.slice(decimals + 1);
50104
- const fractionToKeep = fracPart.slice(0, decimals);
50105
- const sign = intPart.startsWith("-") ? -1 : 1;
50106
- const absInt = BigInt(intPart.replace("-", ""));
50107
- const hasNonZeroAfter = /[1-9]/.test(rest);
50108
- let resultFrac = fractionToKeep;
50097
+ const str = String(value).trim();
50098
+ if (!/^[-+]?\d+(\.\d+)?$/.test(str)) return NaN;
50099
+ if (decimals < 0) return NaN;
50100
+ const sign = str.startsWith("-") ? -1 : 1;
50101
+ const abs = str.replace(/^[-+]/, "");
50102
+ const [intPart, fracPart = ""] = abs.split(".");
50103
+ if (fracPart.length <= decimals) return Number(str);
50104
+ const roundPos = decimals;
50105
+ const roundingDigit = Number(fracPart[roundPos]);
50106
+ const tail = fracPart.slice(roundPos + 1);
50107
+ const hasTail = tail.length > 0 && /[1-9]/.test(tail);
50108
+ let lastKept;
50109
+ if (roundPos > 0) {
50110
+ lastKept = Number(fracPart[roundPos - 1]);
50111
+ } else {
50112
+ lastKept = intPart.length > 0 ? Number(intPart[intPart.length - 1]) : 0;
50113
+ }
50114
+ const isNegative = sign < 0;
50109
50115
  let carry = 0;
50110
- if (roundingDigit > 5 || roundingDigit === 5 && (hasNonZeroAfter || Number(fractionToKeep[decimals - 1] ?? 0) % 2 !== 0)) {
50111
- const num = BigInt(resultFrac || "0") + BigInt(1);
50112
- const max = BigInt(10) ** BigInt(decimals);
50113
- if (num >= max) {
50116
+ if (roundingDigit > 5) {
50117
+ carry = 1;
50118
+ } else if (roundingDigit === 5) {
50119
+ if (hasTail || isNegative || lastKept % 2 === 1) {
50114
50120
  carry = 1;
50115
- resultFrac = "0".repeat(decimals);
50121
+ }
50122
+ }
50123
+ let frac = fracPart.slice(0, roundPos).padEnd(decimals, "0");
50124
+ let int = intPart || "0";
50125
+ if (carry) {
50126
+ if (decimals === 0) {
50127
+ int = (Number(int) + 1).toString();
50116
50128
  } else {
50117
- resultFrac = num.toString().padStart(decimals, "0");
50129
+ let i = decimals - 1;
50130
+ while (i >= 0) {
50131
+ if (frac[i] !== "9") {
50132
+ frac = frac.slice(0, i) + (Number(frac[i]) + 1) + frac.slice(i + 1);
50133
+ break;
50134
+ }
50135
+ frac = frac.slice(0, i) + "0" + frac.slice(i + 1);
50136
+ i--;
50137
+ }
50138
+ if (i < 0) {
50139
+ int = (Number(int) + 1).toString();
50140
+ frac = "0".repeat(decimals);
50141
+ }
50118
50142
  }
50119
50143
  }
50120
- const resultInt = absInt + BigInt(carry);
50121
- const result2 = (sign < 0 ? "-" : "") + resultInt.toString() + (decimals > 0 ? "." + resultFrac.padEnd(decimals, "0") : "");
50122
- return Number(result2);
50144
+ const resultStr = int + (decimals > 0 ? "." + frac : "");
50145
+ return sign * Number(resultStr);
50123
50146
  }
50124
50147
  const fFormatRuNumber = (a, options) => {
50125
50148
  if (typeof a !== "number" || isNaN(a)) return (options == null ? void 0 : options.returnNumber) ? NaN : "";