country-from-iso2

1.0.1 • Public • Published

country-from-iso2

Get country data from ISO 3166-1 alpha-2, which are two-letter country codes defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO).

NPM

Installation

npm install --save country-from-iso2

Run test

npm run test

Usage

// commonJS - Destructuring
const { getCountries, getCurrencySymbol } = require('country-from-iso2');
 
// ES6 - using webapack bundler
import { getCountries, getCurrencySymbol } from 'country-from-iso2';

API

getCountries([include])

Get a list of all countries from https://github.com/mledoze/countries

include parameter is an optional. Contains a list of country's properties to be included in the final result. Check out JSON file at https://github.com/mledoze/countries/blob/master/countries.json for the list of all country's properties.

getCountries(); // retruns everything
 
getCountries(['cca2', 'name']); // gives you an array of countries with two properties only, named 'cca2' and 'name'.

getCountry(iso2)

Get a country data from 'ISO 3166-1 alpha-2'.

getCountry('us'); // case-insensitive

getCurrencySymbol(currency)

Get a country's currency symbol from currency.

getCurrencySymbol('usd') // case-insensitive and return `$`

getCurrencySymbolFromIso2(iso2)

Get a country's currency symbol from 'ISO 3166-1 alpha-2'.

getCurrencySymbolFromIso2('us') // case-insensitive and return `$`

License

MIT

Package Sidebar

Install

npm i country-from-iso2

Weekly Downloads

541

Version

1.0.1

License

MIT

Unpacked Size

8.46 kB

Total Files

7

Last publish

Collaborators

  • abhaydgarg