2.0.8 • Published 5 months ago

iso-countries-lookup v2.0.8

Weekly downloads
431
License
MIT
Repository
github
Last release
5 months ago

iso-countries-lookup npm version

Find country codes (ISO 3166-1 alpha-2) by country names in multiple languages with basic fault tolerance for inputs.

Returns the ISO 3166-1 alpha-2 country code for a given country name. Supports multiple languages based on i18n-iso-countries and also alternative names based on world countries data.

Installation

npm i iso-countries-lookup

Usage

import countryCodeLookup from 'iso-countries-lookup';
countryCodeLookup(input, [options]);
// Finding ISO Code from official names (fastest)
countryCodeLookup('Germany'); // 'DE'
countryCodeLookup('United States of America'); // 'US'
countryCodeLookup('اليونان'); // 'GR'
countryCodeLookup('罗马尼亚'); // 'RO'
countryCodeLookup('Côte d\'Ivoire'); // 'CI'

// Findinding ISO codes from alternative names
countryCodeLookup('Bundesrepublik Deutschland'); // 'DE'
countryCodeLookup('United states'); // US
countryCodeLookup('Iran'); // 'IR'
countryCodeLookup('Cote dIvoire'); // 'CI'

// Finding ISO codes from dirty strings
countryCodeLookup(', Румыния - '); // Return RO
countryCodeLookup(' , DEU') // DE
countryCodeLookup('uk') // UK

// Finding ISO codes from Numeric
countryCodeLookup(184) // CK
countryCodeLookup('004') // AF

// Finding ISO codes from Numeric
countryCodeLookup(184, { numeric: false }) // undefined
countryCodeLookup('004', { numeric: false }) // undefined

Options

ParameterDefaultDescription
numerictrueISO 3166-1 numeric values in input

Returns

The ISO 3166-1 alpha-2 code of a country or undefined.

2.0.8

5 months ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.4

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.0

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago