mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-16 04:57:08 +00:00
* balance fetching * fix tests * bump deps * validate custom token form * equiv values * fix rates saga naming * address review comments
19 lines
512 B
JavaScript
19 lines
512 B
JavaScript
// @flow
|
|
import Big from 'big.js';
|
|
|
|
export function toFixedIfLarger(number: number, fixedSize: number = 6): string {
|
|
return parseFloat(number.toFixed(fixedSize)).toString();
|
|
}
|
|
|
|
// Use in place of angular number filter
|
|
export function formatNumber(number: Big, digits: number = 3): string {
|
|
let parts = number.toFixed(digits).split('.');
|
|
parts[1] = parts[1].replace(/0+/, '');
|
|
if (!parts[1]) {
|
|
parts.pop();
|
|
}
|
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
|
|
return parts.join('.');
|
|
}
|