summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/utils/index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2021-03-11 14:56:28 +0100
committerJules Laplace <julescarbon@gmail.com>2021-03-11 14:56:28 +0100
commite28171ff3679e8e172d438c796751bf823dfe7f8 (patch)
treec167b9d67b8950b85c5037f6c5ede3bf84fdf697 /animism-align/frontend/app/utils/index.js
parent37896f6960f8145a13e2943fbb0cde52da430d30 (diff)
loading peaks correctly
Diffstat (limited to 'animism-align/frontend/app/utils/index.js')
-rw-r--r--animism-align/frontend/app/utils/index.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/animism-align/frontend/app/utils/index.js b/animism-align/frontend/app/utils/index.js
index dc80fee..92aa769 100644
--- a/animism-align/frontend/app/utils/index.js
+++ b/animism-align/frontend/app/utils/index.js
@@ -103,6 +103,26 @@ export const timestampToSeconds = time_str => {
return time_str_parts[0]
}
+export const commatize = (n, radix) => {
+ radix = radix || -1
+ var nums = [], i, counter = 0, r = Math.floor
+ if (radix !== -1 && n > radix) {
+ n /= radix
+ nums.unshift(r((n * 10) % 10))
+ nums.unshift(".")
+ }
+ do {
+ i = r(n % 10)
+ n = r(n / 10)
+ counter += 1
+ if (n && ! (counter % 3))
+ { i = ',' + r(i) }
+ nums.unshift(i)
+ }
+ while (n)
+ return nums.join("")
+}
+
export const percent = n => (n * 100).toFixed(1) + '%'
export const px = (n, w) => Math.round(n * w) + 'px'