spell-vn-number
Version:
Vietnamese number speller
53 lines • 2.54 kB
TypeScript
import { InputNumber, NormalizeOptions, SpellerConfig } from './types';
/**
* Validates an input number, ensures it's a valid string representation.
* @param input The input number to validate
* @param config NormalizeOptions
* @returns A valid string representation of the number
*/
export declare function cleanInputNumber(input: InputNumber, config: NormalizeOptions): string;
/**
* Normalizes a number string by cleaning whitespace and special characters.
* Compatible with IE11 and older browsers.
* @param input The string to normalize
* @param options Options for normalization
* @returns Normalized number string
*/
export declare function normalizeNumberString(input: string, options?: NormalizeOptions): string;
/**
* Removes leading characters from a string.
* If the result was empty after removing all leading characters that match the input character,
* returns the input character (char parameter) instead of an empty string.
*
* @example
* trimLeft('000123', '0') // returns '123'
* trimLeft('000', '0') // returns '0'
* trimLeft('000', '1') // returns '000' (no trimming since no '1's at start)
* trimLeft('111', '1') // returns '1'
*
* @param str The input string
* @param char The character to trim (default '0')
* @returns The string with leading chars removed, or the input char if all matching characters were removed
*/
export declare function trimLeft(str: string, char?: string): string;
/**
* Removes trailing zeros from a string
* @param str The input string
* @param char The character to trim (default '0')
* @param keepOneZeroWhenAllZeros
* @returns The string with trailing chars removed
*/
export declare function trimRight(str: string, char?: string, keepOneZeroWhenAllZeros?: boolean): string;
/**
* Trims redundant zeros at the beginning and end of a number string with configurable behavior
* For integral part: trims leading zeros but always keeps at least one if at start
* For fractional part: trims trailing zeros with configurable behavior
* keepOneZeroWhenAllZeros:
* - When true, fractional part that consists of all zeros will result in a single trailing zero
* - When false, fractional part that consists of all zeros will be completely removed, leaving only the decimal point
* @param config Configuration object with trim settings
* @param numberStr The number string to process
* @returns The trimmed number string
*/
export declare function trimRedundantZeros(config: SpellerConfig, numberStr: string): string;
//# sourceMappingURL=utils.d.ts.map