forked from cartsnitch/cartsnitch
feat: add utility functions with unit tests
Add formatCurrency, formatDate, and storeSlugs utilities in src/utils/ with 21 vitest unit tests covering standard and edge cases. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
export function formatCurrency(
|
||||
cents: number,
|
||||
locale = 'en-US',
|
||||
currency = 'USD'
|
||||
): string {
|
||||
return new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency,
|
||||
}).format(cents / 100);
|
||||
}
|
||||
Reference in New Issue
Block a user