Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
country-currency-map
Advanced tools
Mapping of countries and their primary currency along with currency data.
npm install country-currency-map
var getCountry = require("country-currency-map").getCountry;
getCountry("United States"); //=> { abbreviation: 'US', currency: 'USD' }
getCountry("Canada"); //=> { abbreviation: 'CA', currency: 'CAD' }
var getCurrency = require("country-currency-map").getCurrency;
getCurrency("USD"); //=> { name: 'U.S. Dollar (USD)', symbolFormat: '${#}' }
getCurrency("CAD"); //=> { name: 'Canadian Dollar (CAD)', symbolFormat: 'C${#}' }
var getCurrencyAbbreviation = require("country-currency-map")
.getCurrencyAbbreviation;
getCurrencyAbbreviation("United States"); //=> 'USD'
getCurrencyAbbreviation("Canada"); //=> 'CAD'
var formatCurrency = require("country-currency-map").formatCurrency;
formatCurrency("100,000", "USD"); //=> '$100,000'
formatCurrency("100,000", "EUR"); //=> '€100,000'
This function takes a number and currency abbreviation then returns back the currency string based on the country locale (checks navigator language and defaults to EN). If toLocaleString options are not supported or the value passed is not a number, it will fallback to formatCurrency. Note, NodeJS only support EN locale out of the box. If you need support for other locales please see: https://www.npmjs.com/package/intl
var formatLocaleCurrency = require("country-currency-map").formatLocaleCurrency;
formatLocaleCurrency(100000.5, "USD"); // US locale => '$100.000
formatLocaleCurrency(3000.2, "EUR"); // FR locale => '€3 000,20
There's a third boolean parameter for additional options:
autoFixed
- defaults to true, if value >= 1000 then will set fixed precision to 0locale
- set locale to override navigator settingsabbreviate
- default to false, if true will abbreviate the numerical value. Currently this only supports numbers into the trillions.var formatLocaleCurrency = require("country-currency-map").formatLocaleCurrency;
formatLocaleCurrency(100000.5, "USD", { abbreviate: true }); // => $100k
formatLocaleCurrency(3000.2, "EUR", { abbreviate: true }); // => €3k
formatLocaleCurrency(3000.2, "EUR", { abbreviate: true }); // => €3k
formatLocaleCurrency(3000.2, "USD", { autoFixed: false }); // => $3,000.20
var getCurrencyList = require("country-currency-map").getCurrencyList;
getCurrencyList(); //=> [ { abbr: "AFA", name: "Afghanistan Afghani (AFA)", symbolFormat: "AFA {#}" }, { abbr: "ALL", name: "Albanian Lek (ALL)", symbolFormat:, "ALL {#}" }, ... ]
var getCurrencyAbbreviationFromName = require("country-currency-map")
.getCurrencyAbbreviationFromName;
getCurrencyAbbreviationFromName("U.S. Dollar (USD)"); //=> 'USD'
var getCountryByAbbreviation = require("country-currency-map")
.getCountryByAbbreviation;
getCountryByAbbreviation("US"); //=> 'United States'
FAQs
Mapping of countries and their primary currency.
The npm package country-currency-map receives a total of 6,649 weekly downloads. As such, country-currency-map popularity was classified as popular.
We found that country-currency-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.