Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
country-data-lookup
Advanced tools
Forked from https://github.com/OpenBookPrices/country-data as it is no longer maintained by its developer
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.
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 - see below.currencies
An array of ISO 4217 currency codes with the primary one firstlanguages
An array of ISO 639-2 codes for languages (may not be complete).countryCallingCodes
An array of the international call prefixes for this country.ioc
The International Olympic Committee country codeemoji
The emoji of country's flag.The status
can be one of 'assigned', 'reserved', 'user assigned' or 'deleted'.
Assigned means that the code is properly in the ISO 3166 standard. Reserved means that the code is being prevented from being used. Deleted means that it has been deleted. User Assigned means that for some use cases it is required. Deleted means that it used to be in the standard but is now not.
See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for full details, especially the "User-assigned code elements" and "Reserved code elements" sections.
Countries are ofter grouped into regions. The list of regions is by no means exhaustive, pull requests very welcome for additions.
countries
An array of alpha2
codes for the countries in this region.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 shownsymbol
The currency symbol for the currency (e.g. ¥, $ etc.). Some symbols are not available, in which case
symbol
contains the ISO 4217 code. Credit to bengourley/currency-symbol-map
for the symbol database.A list of languages provided by ISO 639-2;
name
The english name for the languagealpha2
The two letter ISO 639-1 code for the language (may be blank).alpha3
The three letter terminological ISO 639-2 code for the language (may be blank).bibliograpic
The three letter bibliographic ISO 639-2 code for the language (may be blank).To make finding easier there are utility methods that can search the countries and currencies. See examples below.
npm install country-data-lookup
var countries = require('country-data-lookup').countries,
currencies = require('country-data-lookup').currencies,
regions = require('country-data-lookup').regions,
languages = require('country-data-lookup').languages,
callingCountries = require('country-data-lookup').callingCountries;
// .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']
// callingCountries is like countries but only has entries with dialing codes.
// currencies are accessed by their code (uppercase)
console.log( currencies.USD.name ); // 'United States dollar'
// regions are accessed using a camel case name
console.log( regions.europe.countries )
var lookup = require('country-data-lookup').lookup;
// Match a value (grab first from array)
var france = lookup.countries({name: 'France'})[0];
// Or match one of several possible values.
var eurozone_countries = lookup.countries({currencies: 'EUR'});
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:
As this code loads the data from JSON files you need to add the JSON loader to webpack:
npm install json-loader --save-dev
and then include in your webpack.config.js
:
// ...
loaders: [
// other loaders
{ test: /\.json$/, loader: 'json' },
],
// ...
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/kobik/country-data.git
cd country-data
# install the dependencies
npm install .
# Edit the countries.csv
open data/countries.csv
# Convert the raw data (CSV or JS files) to JSON
make
# 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.
FAQs
Country data lookup
The npm package country-data-lookup receives a total of 13 weekly downloads. As such, country-data-lookup popularity was classified as not popular.
We found that country-data-lookup 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.