A Javascript library for formatting regular numbers to a friendly number
MIT License
Make sure you have the following installed:
npm install number-js-formatter
# or
yarn add number-js-formatter
# or
pnpm add number-js-formatter
This library is minimal and doesn't require any configuration.
import { friendlyFormat } from 'number-js-formatter';
const num1 = 1_923_500.156;
const num2 = 1_004_850_000.91332;
const num3 = 1105_830_000_302.9946;
friendlyFormat(num1, { noOfDigitsAfterDecimal: 3 }); // "1.924m"
friendlyFormat(num2, { noOfDigitsAfterDecimal: 4, form: '-ln' }); // "1.0049bln"
friendlyFormat(num3, { noOfDigitsAfterDecimal: 3 }); // "1.106tn"
Read through our contributing guidelines to learn about our submission process, coding rules, and more.