diff options
| author | Adam Soltys <[email protected]> | 2022-09-13 23:18:40 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-13 23:18:40 -0700 |
| commit | dfe32780e0862515eb4b2ddebae9fcfb2198704a (patch) | |
| tree | f8b463ccc51291393c71cc3c95ca3725c74d341b /src/lib | |
| parent | cfdc6ed4a98e1eb60aba653d4403138a8fcaa4c2 (diff) | |
| download | coinos-ui-dfe32780e0862515eb4b2ddebae9fcfb2198704a.tar.gz coinos-ui-dfe32780e0862515eb4b2ddebae9fcfb2198704a.zip | |
currency formatting helpers
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/utils.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js index 0f665ec4..80419a45 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -127,3 +127,13 @@ export const auth = (req) => { let { token } = cookie.parse(req.headers.get('cookie') || ''); return { authorization: `Bearer ${token}` }; }; + +export const f = (s, currency) => + new Intl.NumberFormat('en-US', { + style: 'currency', + currency + }) + .format(s) + .replace('CA', ''); + +export const s = (s) => new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(s); |
