Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
argon-formatter
Advanced tools
Readme
Argon Formatter is universal currency formatter. This is a fork of Smirzaei's currency-formatter except that it provides UMD and ESM builds.
npm install argon-formatter --save
Using currency code
import * as argonFormatter from 'argon-formatter';
argonFormatter.format(1000000, { code: 'USD' });
// => '$1,000,000.00'
argonFormatter.format(1000000, { code: 'GBP' });
// => '£1,000,000.00'
argonFormatter.format(1000000, { code: 'EUR' });
// => '1 000 000,00 €'
Using locale
import * as argonFormatter from 'argon-formatter';
argonFormatter.format(1000000, { locale: 'en-US' });
// => '$1,000,000.00'
argonFormatter.format(1000000, { locale: 'en-GB' });
// => '£1,000,000.00'
argonFormatter.format(1000000, { locale: 'GB' });
// => '£1,000,000.00'
argonFormatter.format(1000000, { locale: 'de-DE' });
// => '1.000.000,00 €'
argonFormatter.format(1000000, { locale: 'nl-NL' });
// => '€1.000.000,00'
import * as argonFormatter from 'argon-formatter';
argonFormatter.findCurrency('USD');
// returns:
// {
// code: 'USD',
// symbol: '$',
// thousandsSeparator: ',',
// decimalSeparator: '.',
// symbolOnLeft: true,
// spaceBetweenAmountAndSymbol: false,
// decimalDigits: 2
// }
argonFormatter.unformat('$10.5', { code: 'USD' })
// => 10.5
argonFormatter.unformat('$1,000,000', { code: 'USD' })
// => 1000000
argonFormatter.unformat('10,5 €', { code: 'EUR' })
// => 10.5
argonFormatter.unformat('1 000 000,00 €', { code: 'EUR' })
// => 1000000
argonFormatter.unformat('1.000,99', { locale: 'de-DE' })
// => 1000.99
argonFormatter.unformat('10\'000 CHF', { code: 'CHF' })
// => 10000
argonFormatter.unformat('10.00 CHF', { code: 'CHF' })
// => 10
argonFormatter.unformat('10,00 CHF', { code: 'CHF' })
// => 1000
Argon Formatter uses accounting under the hood, and you can use its options to override default behavior.
import * as argonFormatter from 'argon-formatter';
argonFormatter.format(1000000, {
symbol: '@',
decimal: '*',
thousand: '^',
precision: 1,
format: '%v %s' // %s is the symbol and %v is the value
});
// => '1^000^000*0 @'
// Different formatting for positive and negative values
argonFormatter.format(-10, {
format: {
pos: '%s%v' // %s is the symbol and %v is the value
neg: '(%s%v)',
zero: '%s%v'
}
});
// => ($10)
const currencies = argonFormatter.currencies();
FAQs
A universal Javascript utility for formatting currency
The npm package argon-formatter receives a total of 16 weekly downloads. As such, argon-formatter popularity was classified as not popular.
We found that argon-formatter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.