Prettier format all js files

This commit is contained in:
George Drummond
2019-01-24 09:38:43 -05:00
parent 20604e6ca9
commit 619bc9fe59
32 changed files with 553 additions and 443 deletions

View File

@@ -8,12 +8,19 @@ export const formatDollars = (value, cents = true) => {
}
export const abbreviateDollars = (value, decimals = 1) => {
if (value === null) { return null } // terminate early
if (value === 0) { return '0' } // terminate early
var b = (value).toPrecision(2).split("e"), // get power
k = b.length === 1 ? 0 : Math.floor(Math.min(b[1].slice(1), 14) / 3), // floor at decimals, ceiling at trillions
c = k < 1 ? value.toFixed(0 + decimals) : (value / Math.pow(10, k * 3) ).toFixed(decimals), // divide by power
d = c < 0 ? c : Math.abs(c), // enforce -0 is 0
e = d + ['', 'k', 'M', 'B', 'T'][k]; // append power
return e;
if (value === null) {
return null
} // terminate early
if (value === 0) {
return '0'
} // terminate early
var b = value.toPrecision(2).split('e'), // get power
k = b.length === 1 ? 0 : Math.floor(Math.min(b[1].slice(1), 14) / 3), // floor at decimals, ceiling at trillions
c =
k < 1
? value.toFixed(0 + decimals)
: (value / Math.pow(10, k * 3)).toFixed(decimals), // divide by power
d = c < 0 ? c : Math.abs(c), // enforce -0 is 0
e = d + ['', 'k', 'M', 'B', 'T'][k] // append power
return e
}