UNPKG

num-beauty

Version:

An ultra lightweight module for formatting numbers into human-friendly strings

103 lines (102 loc) 3.39 kB
export interface CurrencyConfig { symbol: string; position: 'before' | 'after'; } export interface LocaleConfig { code: string; name: string; masks: Record<string, string>; currencies: Record<string, CurrencyConfig>; units: ReadonlyArray<readonly [string, string]>; speech?: { small?: readonly string[]; tens?: readonly string[]; units?: ReadonlyArray<readonly [string, string]>; point?: string; minus?: string; currency?: Record<string, readonly [string, string]>; currencyJoiner?: string; rules?: { tensHyphenate?: boolean; tensJoiner?: string; hundredsJoiner?: string; hundredSuffix?: string; }; hundredsWords?: readonly string[]; hundredOneExact?: string; }; } export type BuiltInLocale = 'en-US' | 'pt-BR' | 'es-ES' | 'de-DE' | 'fr-FR'; export type SupportedLocale = BuiltInLocale | string; export declare function registerLocale(code: string, config: { masks?: Record<string, string>; currencies?: Record<string, CurrencyConfig>; units?: ReadonlyArray<readonly [string, string]>; speech?: { small?: readonly string[]; tens?: readonly string[]; units?: ReadonlyArray<readonly [string, string]>; point?: string; minus?: string; currency?: Record<string, readonly [string, string]>; currencyJoiner?: string; rules?: { tensHyphenate?: boolean; tensJoiner?: string; hundredsJoiner?: string; hundredSuffix?: string; }; hundredsWords?: readonly string[]; hundredOneExact?: string; }; }): void; export declare function hasLocale(code: string): boolean; export declare function getLocale(code: string): { masks: Record<string, string>; currencies: Record<string, CurrencyConfig>; units: ReadonlyArray<readonly [string, string]>; speech?: { small?: readonly string[]; tens?: readonly string[]; units?: ReadonlyArray<readonly [string, string]>; point?: string; minus?: string; currency?: Record<string, readonly [string, string]>; currencyJoiner?: string; rules?: { tensHyphenate?: boolean; tensJoiner?: string; hundredsJoiner?: string; hundredSuffix?: string; }; hundredsWords?: readonly string[]; hundredOneExact?: string; }; } | undefined; export declare function getRegisteredLocales(): string[]; export declare const locales: Record<string, { masks: Record<string, string>; currencies: Record<string, CurrencyConfig>; units: ReadonlyArray<readonly [string, string]>; speech?: { small?: readonly string[]; tens?: readonly string[]; units?: ReadonlyArray<readonly [string, string]>; point?: string; minus?: string; currency?: Record<string, readonly [string, string]>; currencyJoiner?: string; rules?: { tensHyphenate?: boolean; tensJoiner?: string; hundredsJoiner?: string; hundredSuffix?: string; }; hundredsWords?: readonly string[]; hundredOneExact?: string; }; }>; export declare const supportedLocales: { code: string; name: string; }[];