update numbers utils
This commit is contained in:
parent
8652f81ade
commit
adb6b8b1f6
11
dist/utils.js
vendored
11
dist/utils.js
vendored
@ -1,6 +1,9 @@
|
|||||||
const e = (r) => new Intl.NumberFormat("fa-IR").format(Number(r)), i = (r) => String(r).replace(/\d/g, (t) => "۰۱۲۳۴۵۶۷۸۹"[Number(t)]), o = (r) => String(r).replace(/[۰-۹]/g, (n) => String("۰۱۲۳۴۵۶۷۸۹".indexOf(n)));
|
const t = (n) => n == null || n === "" ? "" : new Intl.NumberFormat("fa-IR").format(Number(n)), e = (n) => n == null ? "" : String(n).replace(/\d/g, (r) => "۰۱۲۳۴۵۶۷۸۹"[Number(r)]), i = (n) => n == null ? "" : String(n).replace(
|
||||||
|
/[۰-۹]/g,
|
||||||
|
(r) => String("۰۱۲۳۴۵۶۷۸۹".indexOf(r))
|
||||||
|
);
|
||||||
export {
|
export {
|
||||||
o as toEnDigits,
|
i as toEnDigits,
|
||||||
i as toFaDigits,
|
e as toFaDigits,
|
||||||
e as toFaNumber
|
t as toFaNumber
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,12 +1,16 @@
|
|||||||
export const toFaNumber = (value) => {
|
export const toFaNumber = (value) => {
|
||||||
|
if (value === null || value === undefined || value === "") return "";
|
||||||
return new Intl.NumberFormat("fa-IR").format(Number(value));
|
return new Intl.NumberFormat("fa-IR").format(Number(value));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const toFaDigits = (value) => {
|
export const toFaDigits = (value) => {
|
||||||
|
if (value === null || value === undefined) return "";
|
||||||
return String(value).replace(/\d/g, (d) => "۰۱۲۳۴۵۶۷۸۹"[Number(d)]);
|
return String(value).replace(/\d/g, (d) => "۰۱۲۳۴۵۶۷۸۹"[Number(d)]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const toEnDigits = (value) => {
|
export const toEnDigits = (value) => {
|
||||||
const numberString = String(value);
|
if (value === null || value === undefined) return "";
|
||||||
return numberString.replace(/[۰-۹]/g, (d) => String("۰۱۲۳۴۵۶۷۸۹".indexOf(d)));
|
return String(value).replace(/[۰-۹]/g, (d) =>
|
||||||
|
String("۰۱۲۳۴۵۶۷۸۹".indexOf(d)),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user