@codeshumon/number-to-words
Version:
Convert numbers to spoken words with accurate currency formatting for over 100 countries
25 lines (22 loc) • 1.58 kB
TypeScript
type CountryCode = 'US' | 'GB' | 'BD' | 'IN' | 'AE' | 'MY' | 'PK' | 'CA' | 'QA' | 'SA' | 'AU' | 'AF' | 'AL' | 'DZ' | 'AO' | 'AR' | 'AM' | 'AT' | 'AZ' | 'BH' | 'BY' | 'BE' | 'BJ' | 'BO' | 'BA' | 'BR' | 'BG' | 'BF' | 'KH' | 'CM' | 'CL' | 'CN' | 'CO' | 'CR' | 'HR' | 'CU' | 'CZ' | 'CD' | 'DK' | 'EC' | 'EG' | 'SV' | 'EE' | 'ET' | 'FI' | 'FR' | 'GA' | 'GE' | 'DE' | 'GH' | 'GR' | 'GT' | 'GN' | 'HT' | 'HN' | 'HK' | 'HU' | 'ID' | 'IR' | 'IQ' | 'IE' | 'IL' | 'IT' | 'CI' | 'JP' | 'JO' | 'KZ' | 'KE' | 'KW' | 'KG' | 'LA' | 'LV' | 'LB' | 'LY' | 'LT' | 'MG' | 'MW' | 'ML' | 'MX' | 'MD' | 'MA' | 'MZ' | 'MM' | 'NA' | 'NP' | 'NL' | 'NZ' | 'NI' | 'NE' | 'NG' | 'MK' | 'NO' | 'OM' | 'PS' | 'PA' | 'PY' | 'PE' | 'PH' | 'PL' | 'PT' | 'RO' | 'RU' | 'RW' | 'SN' | 'RS' | 'SL' | 'SG' | 'SK' | 'SI' | 'ZA' | 'KR' | 'SS' | 'ES' | 'LK' | 'SD' | 'SE' | 'CH' | 'SY' | 'TJ' | 'TW' | 'TZ' | 'TH' | 'TN' | 'TR' | 'TM' | 'UG' | 'UA' | 'UY' | 'UZ' | 'VE' | 'VN' | 'YE' | 'ZM' | 'ZW';
interface CurrencyConfig {
major: string;
majorPlural: string;
minor: string;
minorPlural: string;
conjunction: string;
suffix: string;
}
declare const numberToWords: (num: number | string, options?: {
noComa?: boolean;
isAnd?: boolean;
noHypen?: boolean;
titleCase?: boolean;
}) => string;
declare const numberToCurrencyWords: (amount: number | string, countryCode?: CountryCode, options?: {
noComa?: boolean;
isAnd?: boolean;
noHypen?: boolean;
titleCase?: boolean;
}) => string;
export { type CountryCode, type CurrencyConfig, numberToCurrencyWords, numberToWords };