UNPKG

shuzi

Version:

Chinese Number Format | 中文数字格式

44 lines (43 loc) 1.28 kB
export interface NumberFormatOptions { /** * @default 'decimal' */ style?: 'decimal' | 'currency'; /** * The maximum number of fraction digits to use. The default for plain number formatting is 3 and * possible values from 0 to 100. The default for currency formatting is 2 and possible values * from 0 to 4. * * 最大小数位长度。普通数字默认值为 3,取值范围 0-100。货币金额默认值为 2,取值范围 0-4。 */ maximumFractionDigits?: number; } export type Locale = 'zh-CN-small' | 'zh-CN-big' | 'zh-HK-small' | 'zh-HK-big' | 'zh-TW-small' | 'zh-TW-big'; export declare class NumberFormat { private locale; private options?; private script; private intl; constructor(locale: Locale, options?: NumberFormatOptions | undefined); format(value: number | string): string; /** * 整数部分格式化 */ private _formatSignificant; /** * 整数部分四位一组格式化 */ private _formatSignificantGroup; /** * 小数部分格式化 */ private _formatFragment; /** * 金额小数部分格式化 */ private _formatFragmentCurrency; /** * 校验数字是否有效 */ private _validate; }