Skip to content

relativeUnitFormatter
@localizer/format-number 1.1.1

A customizable formatter designed to represent absolute changes in measurement values, paired with a specified unit. This utility simplifies the comparison of two values by expressing their difference in a concise and readable format.

Usage

typescript
import { 
relativeUnitFormatter
} from '@localizer/format-number';
const
formatter
=
relativeUnitFormatter
('gram', {
notation
: 'compact',
maximumSignificantDigits
: 2,
unitDisplay
: 'narrow',
}); const
result
=
formatter
(3500, 5000);

Represents the change from an initial reference value (first argument) to an updated value (second argument).

See formatter options for configuration details.

Demo

compact
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
─── unset ───
gram
Please Select
LocaleLocalized value
en-US  American English+1,500 g
fr-FR  French (France)+1 500 g
de-DE  German (Germany)+1.500 g
fi-FI  Finnish (Finland)+1 500 g
sv-FI  Swedish (Finland)+1 500 g
ko-KR  Korean (South Korea)+1,500g
hi-IN  Hindi (India)+1,500 ग्रा॰

See also