summaryrefslogtreecommitdiffstats
path: root/web_src/js/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/utils.js')
-rw-r--r--web_src/js/utils.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/web_src/js/utils.js b/web_src/js/utils.js
index 67f8f1cc98..f01f2d3b22 100644
--- a/web_src/js/utils.js
+++ b/web_src/js/utils.js
@@ -90,3 +90,10 @@ export function strSubMatch(full, sub) {
}
return res;
}
+
+// pretty-print a number using locale-specific separators, e.g. 1200 -> 1,200
+export function prettyNumber(num, locale = 'en-US') {
+ if (typeof num !== 'number') return '';
+ const {format} = new Intl.NumberFormat(locale);
+ return format(num);
+}