Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@data-sets/countries

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@data-sets/countries

Static data-set of countries, with additional methods for convenience.

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

@data-sets/countries

NPM CI Typescript

A static list of countries to use in your own projects & services.

import countries from '@data-sets/countries';
// or
// const countries = require('@data-sets/countries');

console.log(countries.findByCode('US'));
// { id: 'Q30',
//   name: 'United States of America',
//   iso2: 'US',
//   iso3: 'USA',
//   phonePrefix: '+1',
//   currencyId: 'Q4917',
//   currencyCode: 'USD',
//   population: '331449281',
//   latlon: [ '-98.5795', '39.828175' ],
//   emergencyPhone: '911',
//   internetTlds: [ '.us' ],
//   continentId: 'Q49',
//   continentName: 'North America',
//   capitalId: 'Q61',
//   capitalName: 'Washington, D.C.' }

console.log(countries.findByCode('GB'));
// { id: 'Q145',
//   name: 'United Kingdom',
//   iso2: 'GB',
//   iso3: 'GBR',
//   phonePrefix: '+44',
//   currencyId: 'Q25224',
//   currencyCode: 'GBP',
//   population: '67326569',
//   latlon: [ '-2.0', '54.6' ],
//   emergencyPhone: '112',
//   internetTlds: [ '.uk', '.gb' ],
//   continentId: 'Q46',
//   continentName: 'Europe',
//   capitalId: 'Q84',
//   capitalName: 'London' }

Install

npm install --save @data-sets/countries

API

data

Import the complete list of countries, as an array, so you can filter/find/map/reduce as you please:

import { data } from '@data-sets/countries';

const selection = data.filter(({ currencyCode }) => {
  return ['USD', 'GBP', 'EUR'].includes(currencyCode);
});
const countries = require('@data-sets/countries');

const selection = countries.data.filter(({ currencyCode }) => {
  return ['USD', 'GBP', 'EUR'].includes(currencyCode);
});

findByCode

Get a country by their ISO 3166-1 alpha-2 or ISO 3166-1 alpha-3 code. Returns undefined if the country is not found.

import { findByCode } from '@data-sets/countries';

const country = findByCode('US');
const countries = require('@data-sets/countries');

const country = countries.findByCode('USA');

Notes

Keywords

static

FAQs

Package last updated on 03 Sep 2023

Did you know?

Socket

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.

Install

Related posts