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
Locale | Localized value |
---|---|
en-US | +1,500 g |
fr-FR | +1 500 g |
de-DE | +1.500 g |
fi-FI | +1 500 g |
sv-FI | +1 500 g |
ko-KR | +1,500g |
hi-IN | +1,500 ग्रा॰ |