Created
November 6, 2022 15:53
-
-
Save hendryfoe/9881f04964bbccece7d1636408863fc9 to your computer and use it in GitHub Desktop.
format currency utility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function formatCurrency( | |
value: number, | |
locales: string | string[] = 'id', | |
options: Intl.NumberFormatOptions = { style: 'currency', currency: 'IDR', minimumFractionDigits: 0 } | |
) { | |
return new Intl.NumberFormat(locales, options).format(value); | |
} | |
export function formatCurrencyWithoutPrefix(value: number, locales: string | string[] = 'id') { | |
return formatCurrency(value, locales, {}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment