const persianDigits = [ '۱' , '۲' , '۳' , '۴' , '۵' , '۶' , '۷' , '۸' , '۹' , '۰' ] ; const englishDigits = [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '0' ] ; export const englishNumber = ( digit ) => { for ( let i = 0 ; i < 10 ; i ++ ) { digit = digit . replace ( new RegExp ( persianDigits [ i ] , 'g' ) , englishDigits [ i ] ) ; } return digit ; } ; export const persianNumber = ( number ) => { return new Intl . NumberFormat ( 'fa-IR' ) . format ( number ) ; } ; export const getPrice = ( price , withUnit = true ) => { const formattedPrice = new Intl . NumberFormat ( 'fa-IR' , { currency : 'IRR' , } ) . format ( price ) ; return withUnit ? `${ formattedPrice } تومان` : formattedPrice ; } ; export const formattedNumber = ( value , places ? ) => { const number = typeof value === 'string' ? Number ( value ) : value ; return roundNumber ( number , places ) . toLocaleString ( ) ; } ; const roundNumber = ( num , places ? ) => { if ( ! places ) { return Math . round ( num ) ; } const val = Math . pow ( 10 , places ) ; return Math . round ( num * val ) / val ; } ;