Bunch of website stuff

This commit is contained in:
Michael Jackson
2016-05-20 11:58:58 -07:00
parent 7e29e21483
commit 87524d4947
25 changed files with 784 additions and 162 deletions

View File

@ -0,0 +1,15 @@
export const formatNumber = (n) => {
const digits = String(n).split('')
const groups = []
while (digits.length)
groups.unshift(digits.splice(-3).join(''))
return groups.join(',')
}
export const parseNumber = (s) =>
parseInt(s.replace(/,/g, ''), 10)
export const formatPercent = (n, fixed = 1) =>
String((n.toPrecision(2) * 100).toFixed(fixed))