UNPKG

chinese-numbers-to-arabic

Version:
43 lines (37 loc) 1.71 kB
/** * Converts a string like 8千3萬 into 8千3百萬 (8300*10000). * @param {string} str - The original string. * @returns {string} The converted, expanded string. */ declare const addMissingUnits: (str: string) => string; /** * Checks whether a character is an Arabic number [0-9] and not a Chinese * number or another character. * @returns {boolean} True if character is from 0 to 9. */ declare const isArabicNumber: (character: string) => boolean; /** * Checks whether a character is a Chinese number character. * @param {number|string} A single character to be checked. * @returns {boolean} True if it's a Chinese number character or Chinese-style * Arabic numbers (0-9). */ declare const isChineseNumber: (character: string) => boolean; /** * Converts multiple Chinese numbers in a string into Arabic numbers, and * returns the translated string containing the original text but with Arabic * numbers only. * @param {number} [minimumCharactersInNumber] - Optionally, how many * characters minimum must be in a number to be converted. Sometimes a * good setting would be 2, because otherwise we will convert geographic * names like 九龍站 into 9龍站. * @returns {string} The translated string with Arabic numbers only. */ declare const toArabicString: (source: string, minimumCharactersInNumber?: number) => string; /** * Returns the result of the conversion of Chinese number into an `Integer`. * @param {string} source string that you want to convert * @returns {number} The Chinese number converted to integer. */ declare const toInteger: (source: string) => number; export { addMissingUnits, isArabicNumber, isChineseNumber, toArabicString, toInteger };