From c15c9b3565ec94452b8d102f517e15859b72ee05 Mon Sep 17 00:00:00 2001 From: trevor-anderson Date: Thu, 22 Dec 2022 07:46:53 -0500 Subject: [PATCH] docs: add some jsdoc to formatNum --- src/utils/formatNum.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/formatNum.ts b/src/utils/formatNum.ts index 5fc7dfea..fb0aca4f 100644 --- a/src/utils/formatNum.ts +++ b/src/utils/formatNum.ts @@ -1,7 +1,14 @@ const intlCurrencyFmt = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }); const intlPercentageFmt = new Intl.NumberFormat("en-US", { style: "percent" }); +/** + * These methods take as an argument a *WHOLE* integer (do not include any decimal places) + * and returns a string representation based on expected units using the `en-US` locale. + * + * - toCurrencyStr `123456` becomes `"$1,234.56"` + * - toPercentageStr `123` becomes `"123%"` + */ export const formatNum = { - toCurrencyStr: (num: number) => intlCurrencyFmt.format(num), + toCurrencyStr: (num: number) => intlCurrencyFmt.format(num / 100), toPercentageStr: (num: number) => intlPercentageFmt.format(num) };