UNPKG

num-beauty

Version:

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

24 lines (23 loc) 837 B
import { type SupportedLocale } from '../locales/index.js'; import { type RoundingMode } from './rounding.service.js'; export interface NumberPart { type: 'integer' | 'decimal' | 'fraction' | 'group' | 'currency' | 'percentSign' | 'unit' | 'minusSign' | 'plusSign' | 'literal'; value: string; } export interface BeautifyToPartsOptions { locale?: SupportedLocale; decimals?: number; abbreviated?: boolean; stripZeros?: boolean; roundingMode?: RoundingMode; currency?: string; showSymbol?: boolean; showCode?: boolean; bytes?: boolean; bytesBinary?: boolean; bytesLongFormat?: boolean; percentage?: boolean; percentageMultiply?: boolean; percentageAddSpace?: boolean; } export declare function beautifyToParts(number: number, options?: BeautifyToPartsOptions): NumberPart[];