How to use the currency-formatter.currencies function in currency-formatter

To help you get started, we’ve selected a few currency-formatter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jozsi / mystash / src / backend / models / wallet.js View on Github external
name: {
    type: String,
    required: true,
    trim: true,
  },
  balance: {
    type: Number,
    default: 0,
  },
  initialBalance: {
    type: Number,
  },
  currency: {
    type: String,
    default: 'USD',
    enum: currencyFormatter.currencies.map(currency => currency.code),
  },
  user: {
    type: db.Schema.Types.ObjectId,
    ref: 'User',
    required: true,
  },
}, {
  toJSON: transformer,
  toObject: transformer,
});

walletSchema.virtual('formattedBalance').get(function formatValue() {
  return currencyValue(this.balance, this.currency);
});

walletSchema.pre('save', function preSave(next) {

currency-formatter

A simple Javascript utility that helps you to display currency properly

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis