PHP 8.2.30
Preview: fixedDecimalValue.ts Size: 946 B
/home/byroehnu/easepaybiz.easetack.com/node_modules/react-currency-input-field/src/components/utils/fixedDecimalValue.ts

export const fixedDecimalValue = (
  value: string,
  decimalSeparator: string,
  fixedDecimalLength?: number
): string => {
  if (fixedDecimalLength !== undefined && value.length > 1) {
    if (fixedDecimalLength === 0) {
      return value.replace(decimalSeparator, '');
    }

    if (value.includes(decimalSeparator)) {
      const [int, decimals] = value.split(decimalSeparator);

      if (decimals.length === fixedDecimalLength) {
        return value;
      }

      if (decimals.length > fixedDecimalLength) {
        return `${int}${decimalSeparator}${decimals.slice(0, fixedDecimalLength)}`;
      }
    }

    const reg =
      value.length > fixedDecimalLength
        ? new RegExp(`(\\d+)(\\d{${fixedDecimalLength}})`)
        : new RegExp(`(\\d)(\\d+)`);

    const match = value.match(reg);
    if (match) {
      const [, int, decimals] = match;
      return `${int}${decimalSeparator}${decimals}`;
    }
  }

  return value;
};

Directory Contents

Dirs: 1 × Files: 15

Name Size Perms Modified Actions
__tests__ DIR
- drwxr-xr-x 2026-03-14 01:49:06
Edit Download
127 B lr--r--r-- 2026-03-14 01:49:06
Edit Download
195 B lrw-r--r-- 2026-03-05 00:20:02
Edit Download
2.62 KB lrw-r--r-- 2026-03-05 00:20:06
Edit Download
295 B lrw-r--r-- 2026-03-05 00:20:10
Edit Download
946 B lrw-r--r-- 2026-03-05 00:20:11
Edit Download
5.26 KB lrw-r--r-- 2026-03-05 00:20:12
Edit Download
1.25 KB lrw-r--r-- 2026-03-05 00:20:13
Edit Download
475 B lrw-r--r-- 2026-03-05 00:20:13
Edit Download
258 B lrw-r--r-- 2026-03-05 00:20:14
Edit Download
84 B lrw-r--r-- 2026-03-05 00:20:14
Edit Download
718 B lrw-r--r-- 2026-03-05 00:20:15
Edit Download
1.15 KB lrw-r--r-- 2026-03-05 00:20:15
Edit Download
320 B lrw-r--r-- 2026-03-05 00:20:16
Edit Download
280 B lrw-r--r-- 2026-03-05 00:20:16
Edit Download
1.41 KB lrw-r--r-- 2026-03-05 00:20:16
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).