How to use the currency-formatter/currencies.find 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 brave / ethereum-remote-client / ui / app / helpers / confirm-transaction / util.js View on Github external
export function formatCurrency (value, currencyCode) {
  const upperCaseCurrencyCode = currencyCode.toUpperCase()

  return currencies.find(currency => currency.code === upperCaseCurrencyCode)
    ? currencyFormatter.format(Number(value), { code: upperCaseCurrencyCode, style: 'currency' })
    : value
}
github brave / ethereum-remote-client / ui / app / components / pending-tx / confirm-send-token.js View on Github external
ConfirmSendToken.prototype.convertToRenderableCurrency = function (value, currencyCode) {
  const upperCaseCurrencyCode = currencyCode.toUpperCase()

  return currencies.find(currency => currency.code === upperCaseCurrencyCode)
    ? currencyFormatter.format(Number(value), {
      code: upperCaseCurrencyCode,
    })
    : value
}
github brave / ethereum-remote-client / ui / app / helpers / utils / confirm-tx.util.js View on Github external
export function formatCurrency (value, currencyCode) {
  const upperCaseCurrencyCode = currencyCode.toUpperCase()

  return currencies.find(currency => currency.code === upperCaseCurrencyCode)
    ? currencyFormatter.format(Number(value), { code: upperCaseCurrencyCode, style: 'currency' })
    : value
}
github brave / ethereum-remote-client / ui / app / components / send / currency-display.js View on Github external
CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValue) {
  const { primaryCurrency, convertedCurrency, conversionRate } = this.props

  let convertedValue = conversionUtil(nonFormattedValue, {
    fromNumericBase: 'dec',
    fromCurrency: primaryCurrency,
    toCurrency: convertedCurrency,
    numberOfDecimals: 2,
    conversionRate,
  })
  convertedValue = Number(convertedValue).toFixed(2)

  const upperCaseCurrencyCode = convertedCurrency.toUpperCase()

  return currencies.find(currency => currency.code === upperCaseCurrencyCode)
    ? currencyFormatter.format(Number(convertedValue), {
      code: upperCaseCurrencyCode,
    })
    : convertedValue
}

currency-formatter

A simple Javascript utility that helps you to display currency properly

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis