JSPM

countries-names

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 56
  • Score
    100M100P100Q68949F
  • License MIT

A-Z list of country names and their codes

Package Exports

  • countries-names

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (countries-names) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

countries-names

A-Z list of countries for JavaScript Programmers. Supports NodeJS and all browsers

Build Status Code Coverage version MIT License Code of Conduct

Installation

To use with node:

npm install countries-names

Then in the console:

const countriesNames = require('countries-names');

To use directly in the browser:

<script src="path/to/yourCopyOf/countries-names.js"></script>

<script>

  console.log(Cnames.all());
  
</script>

or the minified version:

<script src="path/to/path/to/yourCopyOf/countries-names.min.js"></script>

Usage

Returns an array of all country names and their codes. [{name:'Afghanistan', code: 'AF'},...]

all()

Returns an array of country names ['Afghanistan', 'Albania', ...]

names()

Returns an array of country codes ['AF', 'AL', ...]

codes()

Returns the country name which matches the country code, or undefined if no country matches.

nameByCode(code)

Returns the country code which matches the country name, or undefined if no code matches.

codeByName(country)