Security News
Internet Archive Hacked, 31 Million Record Compromised
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
country-data
Advanced tools
There are lots of little bits of data that you often need relating to countries, and I couldn't find any easy to use source of it. So I compiled it all here.
This code base may change a bit until it hits 0.1.x
- feel free to use it, but be sure to check between upgrades.
I suspect that many of the currencies
entries on the countries may be wrong. Help checking them would be appreciated.
The data currently provided for each country is:
name
The english name for the countryalpha2
The ISO 3166-1 alpha 2 codealpha3
The ISO 3166-1 alpha 3 codestatus
: The ISO status of the entry: either 'assigned' or 'reserved'.currencies
An array of ISO 4217 currency codes with the primary one firstcountryCallingCodes
An array of the international call prefixes for this country.It is not that useful to just have the currency code(s) for a country, so included is currency data too:
name
The english name for the currencycode
The ISO 4217 codenumber
The ISO 4217 numberdecimals
The number of decimal digits conventionally shownnpm install country-data
var countries = require('country-data').countries,
currencies = require('country-data').currencies;
// .all gives you an array of all entries
console.log( countries.all );
console.log( currencies.all );
// countries are found using alpha2 or alpha3 (both uppercase)
console.log( countries.BE.name ); // 'Belgium'
console.log( countries.FRA.currencies ); // ['EUR']
// currencies are accessed by their code (uppercase)
console.log( currencies.USD.name ); // 'United States dollar'
It is very simple for now - feel free to contribute more helpful accessors.
More data for each country is most welcome. Obvious things that it might be nice to add are:
The final format is JSON, but it is easier to work with CSV. Hence in the data
folder there are CSV files and scripts that convert them to JSON. Please don't
edit the JSON directly, but do it via the CSV.
These are the steps required:
# Clone the repo (or better your fork of it)
git clone https://github.com/OpenBookPrices/country-data.git
cd country-data
# install the dependencies
npm install .
# Edit the countries.csv
open countries.csv
# Convert the CSV to JSON
node data/country_csv_to_json.js > data/countries.json
node data/currency_csv_to_json.js > data/currencies.json
# Run the tests
mocha
# If all is ok commit and push
git add .
git commit
git push
# Then send a pull request with your changes. Ideally use several small commits,
# and reference a source that backs up the change.
The currency data was copied from the Wikipedia ISO 4217 page.
The country calling codes came from the Wikipedia country calling codes page.
v0.0.7
FAQs
Data about countries - like their ISO codes and currencies
The npm package country-data receives a total of 53,861 weekly downloads. As such, country-data popularity was classified as popular.
We found that country-data 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.
Security News
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
Security News
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.