UNPKG

422 BJavaScriptView Raw
1import { bnToBn } from '../bn/toBn.js';
2import { formatDecimal } from './formatDecimal.js';
3import { getSeparator } from './getSeparator.js';
4/**
5 * @name formatNumber
6 * @description Formats a number into string format with thousand separators
7 */
8export function formatNumber(value, { locale = 'en' } = {}) {
9 const { thousand } = getSeparator(locale);
10 return formatDecimal(bnToBn(value).toString(), thousand);
11}