How to use the currency-formatter.findCurrency 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 tohjustin / coincharts / src / components / BigAmount / BigAmount.js View on Github external
const BigAmount = ({ type, showPlusMinusSymbol, value, currency }) => {
  switch (type) {
    case "currency": {
      const { decimalSeparator, spaceBetweenAmountAndSymbol, symbol, symbolOnLeft } = currencyFormatter.findCurrency(
        currency,
      );
      const formattedValue = currencyFormatter.format(Math.abs(value), {
        code: currency,
        symbol: "",
      });
      const [integerValue, decimalValue] = formattedValue.split(decimalSeparator);
      const optionalSpacing = spaceBetweenAmountAndSymbol ? " " : "";

      return (
        
          {showPlusMinusSymbol && value > 0 && {PLUS_SYMBOL}}
          {showPlusMinusSymbol && value < 0 && {MINUS_SYMBOL}}
          {symbolOnLeft && {`${symbol}${optionalSpacing}`}}
          {integerValue &amp;&amp; <span>{integerValue}</span>}
          {decimalValue &amp;&amp; {`${decimalSeparator}${decimalValue}`}}
github kresusapp / kresus / shared / helpers.js View on Github external
symbolFor: c => {
        if (!currency.isKnown(c)) {
            throw new Error(`Unknown currency: ${c}`);
        }
        return findCurrency(c).symbol;
    },
    makeFormat: c => {
github kresusapp / kresus / shared / helpers.js View on Github external
    isKnown: c => typeof findCurrency(c) !== 'undefined',
    symbolFor: c => {
github kresusapp / kresus / shared / helpers.js View on Github external
makeFormat: c =&gt; {
        if (!currency.isKnown(c)) {
            throw new Error(`Unknown currency: ${c}`);
        }
        let { decimalDigits } = findCurrency(c);
        return amount =&gt; {
            let am = Math.abs(amount) &lt; Math.pow(10, -decimalDigits - 2) ? 0 : amount;
            return currencyFormatter(am, { code: c });
        };
    }
};

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