15 lines
478 B
TypeScript
15 lines
478 B
TypeScript
export const toPersian = (n: number | string | undefined | null) => {
|
||
if (n === undefined || n === null) return "";
|
||
return n.toString().replace(/\d/g, d => '۰۱۲۳۴۵۶۷۸۹'[parseInt(d)]);
|
||
};
|
||
|
||
export const toEnglishDigits = (str: string) => {
|
||
if (!str) return "";
|
||
return str.replace(/[۰-۹]/g, d => '۰۱۲۳۴۵۶۷۸۹'.indexOf(d).toString());
|
||
};
|
||
|
||
export function cn(...classes: (string | boolean | undefined)[]) {
|
||
return classes.filter(Boolean).join(" ");
|
||
}
|
||
|