Co-authored-by: Mikhail Bashkirov <mikhail.bashkirov@ing.com> Co-authored-by: Thijs Louisse <thijs.louisse@ing.com> Co-authored-by: Joren Broekema <joren.broekema@ing.com> Co-authored-by: Gerjan van Geest <gerjan.van.geest@ing.com> Co-authored-by: Erik Kroes <erik.kroes@ing.com> Co-authored-by: Lars den Bakker <lars.den.bakker@ing.com>
942 B
942 B
Number
The number formatter returns a number based on the locale by using Intl NumberFormat specification.
Features
- formatNumber: returns a formatted number based on locale
- formatNumberToParts: returns a formatted number in parts based on locale
- getFractionDigits: returns the fraction digit for a certain currency
- getGroupSeparator: returns the group separator based on locale
- getDecimalSeparator: returns the decimal separator based on locale
How to use
Installation
npm i --save @lion/localize;
Example
import { formatNumber } from '@lion/localize';
function numberExampleFunction () {
const number = 2000;
const options = { style: 'currency', currency: 'EUR', currencyDisplay: 'code' };
return formatNumber(number, options) // 'EUR 2,000.00' for British locale
}