UNPKG

nambas

Version:

A simple JS library to format numbers using in-built Intl.NumberFormat

52 lines 1.55 kB
export type TNambaParameter = number | string | bigint; export declare enum ENambaFormat { /** Thousands format */ THOUSANDS = "0,0", /** French percentage format */ FRENCH_PERCENTAGE = "0,0 %", /** German percentage format */ GERMAN_PERCENTAGE = "0 %" } export type TNambaFormat = `${ENambaFormat}`; export declare enum EStyle { /** (default) for plain number formatting */ DECIMAL = "decimal", /** For currency formatting */ CURRENCY = "currency", /** For percent formatting */ PERCENT = "percent", /** For unit formatting */ UNIT = "unit" } export type TStyle = `${EStyle}`; export interface IFormatOptions { currency?: string; decimals?: number; locale?: string; style?: TStyle; } export declare enum EFormatToken { /** Basic digit placeholder */ DIGIT = "0", /** Fixed decimal places, e.g., 0.00 */ FIXEDDECIMAL = "0.00", /** Thousands separator */ THOUSANDS = "0,0", /** Abbreviated format (k, M, B, T) */ ABBREVIATED = "0a", /** Ordinal numbers (1st, 2nd, 3rd) */ ORDINAL = "0o", /** Percentage (e.g., 50%) */ PERCENT = "0%", /** Percentage with decimals (e.g., 12.34%) */ DECIMALPERCENT = "0.00%", /** Currency (symbol will be inserted dynamically) */ CURRENCY = "@", /** Scientific notation (e.g., 1.23e+4) */ SCIENTIFIC = "0e+0", /** Human-readable duration (e.g., 1h 20m) */ DURATION = "0d", /** Byte size (e.g., 1.5MB) */ DATASIZE = "0b" } //# sourceMappingURL=types.d.ts.map