Skip to content

Commit

Permalink
Create formatter.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 4, 2024
1 parent 4413557 commit 256e068
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/utils/formatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// utils/formatter.js

// Data formatting utility
class Formatter {
static formatCurrency(amount, currency = 'USD') {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: currency,
}).format(amount);
}

static formatDate(date) {
return new Intl.DateTimeFormat('en-US').format(new Date(date));
}

static formatResponse(data) {
return {
success: true,
data: data,
};
}
}

module.exports = Formatter;

0 comments on commit 256e068

Please sign in to comment.