From dfe32780e0862515eb4b2ddebae9fcfb2198704a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 13 Sep 2022 23:18:40 -0700 Subject: currency formatting helpers --- src/lib/utils.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/lib') 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); -- cgit v1.2.3