diff options
author | Brian Kim <brian@tagg.id> | 2021-06-15 17:15:43 +0900 |
---|---|---|
committer | Brian Kim <brian@tagg.id> | 2021-06-15 17:15:43 +0900 |
commit | 4a422e43c6a6deaeff5d8fcc692138454653e4b9 (patch) | |
tree | 2e86ab879ea35e879581eb64be955d0e5481ff80 /src/utils/common.ts | |
parent | c57b4959c90cec90dd0936f75a9086a4430b66b1 (diff) | |
parent | db0678d647f774dcb1cd60513985d9b6fbd0e28b (diff) |
Merge with master
Diffstat (limited to 'src/utils/common.ts')
-rw-r--r-- | src/utils/common.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils/common.ts b/src/utils/common.ts index cfd9244a..1956e811 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -233,3 +233,8 @@ export const badgesToDisplayBadges = ( img: badgeToImgMap[b.category + b.name], })); }; + +// Documentation: https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript +export const numberWithCommas = (digits: number) => { + return digits.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); +}; |