API / Utilities / FormatUnitScale

FormatUnitScale: object

Defined in: src/libs/format-number/types.ts:51

Custom unit scale for numeric formatting.

scale describes the unit table in one of two forms:

  • {base, postfixes} — geometric progression: postfixes[i] is bound to factor = base^i (e.g. {base: 1024, postfixes: ['B','KB','MB']}).
  • FormatUnitScaleEntry[] — arbitrary factors; required for non-linear scales (e.g. [{factor:1,postfix:'s'},{factor:60,postfix:'min'},{factor:3600,postfix:'h'}]).

delimiter is the shared string placed between the scaled value and the
postfix. Defaults to a locale-aware space; pass '' to suppress it.

The normalized scale is cached by object identity, so for best performance
reuse the same units object across formatNumber calls instead of
creating a new inline literal on every render.

Type declaration

Name Type
delimiter? string
scale { base: number; postfixes: FormatI18nString[]; } | FormatUnitScaleEntry[]