num-beauty
Version:
An ultra lightweight module for formatting numbers into human-friendly strings
32 lines (31 loc) • 2.54 kB
TypeScript
import { type SupportedLocale, registerLocale, hasLocale, getLocale, getRegisteredLocales } from './locales/index.js';
import { type RoundingMode, round } from './services/rounding.service.js';
import { applyMask } from './services/mask.service.js';
import { abbreviateNumber } from './services/abbreviation.service.js';
import { formatNumber } from './services/formatting.service.js';
import { formatCurrency, type CurrencyOptions } from './services/currency.service.js';
import { type BytesOptions } from './services/bytes.service.js';
import { formatPercentage, type PercentageOptions } from './services/percentage.service.js';
import { Num, num, type NumPlugin, type NumPluginContext, type NumPluginServices, type NumState } from './fluent.js';
import { toAccessibleString, type AccessibleOptions } from './services/accessibility.service.js';
import { unbeautify, type UnbeautifyOptions } from './services/parsing.service.js';
import { beautifyToParts, type NumberPart, type BeautifyToPartsOptions } from './services/parts.service.js';
import { generateSmartTicks } from './services/charts.service.js';
import { formatTabular } from './services/tabular.service.js';
import { getChartJsCallback, getRechartsFormatter } from './services/adapters.service.js';
import { formatBytes as formatBytesFn } from './services/units.service.js';
import { formatDuration as formatDurationFn } from './services/duration.service.js';
export * from './services/units.service.js';
export * from './services/duration.service.js';
import { type CurrencyConfig } from './locales/index.js';
export interface NumBeautyOptions {
locale?: SupportedLocale;
decimals?: number;
abbreviated?: boolean;
stripZeros?: boolean;
roundingMode?: RoundingMode;
mask?: string;
currency?: string;
}
export declare function beautify(number: number | bigint, options?: NumBeautyOptions): string;
export { RoundingMode, round, applyMask, formatNumber, registerLocale, hasLocale, getLocale, getRegisteredLocales, abbreviateNumber, formatCurrency, toAccessibleString, unbeautify, formatPercentage, formatBytesFn as formatBytes, formatDurationFn as formatDuration, beautifyToParts, generateSmartTicks, formatTabular, getChartJsCallback, getRechartsFormatter, Num, num, type NumPlugin, type NumPluginContext, type NumPluginServices, type NumState, type SupportedLocale, type CurrencyOptions, type BytesOptions, type PercentageOptions, type AccessibleOptions, type UnbeautifyOptions, type BeautifyToPartsOptions, type NumberPart, type CurrencyConfig, };