项目作者: ecrmnn

项目描述 :
🇳🇴  Lookup information with ISO 3166-1 alpha-2, ISO 3166-1 alpha-3 and ISO 3166-1 numeric
高级语言: TypeScript
项目地址: git://github.com/ecrmnn/iso-3166-1.git
创建时间: 2016-03-09T17:03:32Z
项目社区:https://github.com/ecrmnn/iso-3166-1

开源协议:

下载


iso-3166-1

Lookup information with ISO 3166-1 alpha-2, ISO 3166-1 alpha-3 and ISO 3166-1 numeric

Build Status
npm version
npm version
npm version

Installation

  1. npm install iso-3166-1 --save

Usage

Get country by ISO 3166-1 Alpha-2

  1. const iso = require('iso-3166-1');
  2. console.log(iso.whereAlpha2('no'));
  3. /** Returns:
  4. {
  5. country: 'Norway',
  6. alpha2: 'NO',
  7. alpha3: 'NOR',
  8. numeric: '578'
  9. }
  10. */

Get country by ISO 3166-1 Alpha-3

  1. const iso = require('iso-3166-1');
  2. console.log(iso.whereAlpha3('nor'));
  3. /** Returns:
  4. {
  5. country: 'Norway',
  6. alpha2: 'NO',
  7. alpha3: 'NOR',
  8. numeric: '578'
  9. }
  10. */

Get country by ISO 3166-1 Numeric

  1. const iso = require('iso-3166-1');
  2. console.log(iso.whereNumeric(578));
  3. /** Returns:
  4. {
  5. country: 'Norway',
  6. alpha2: 'NO',
  7. alpha3: 'NOR',
  8. numeric: '578'
  9. }
  10. */

Get country by country name

  1. const iso = require('iso-3166-1');
  2. console.log(iso.whereCountry('NORWAY'));
  3. /** Returns:
  4. {
  5. country: 'Norway',
  6. alpha2: 'NO',
  7. alpha3: 'NOR',
  8. numeric: '578'
  9. }
  10. */

Get all countries

  1. const iso = require('iso-3166-1');
  2. console.log(iso.all());
  3. /** Returns:
  4. [
  5. {
  6. country: 'Norway',
  7. alpha2: 'NO',
  8. alpha3: 'NOR',
  9. numeric: '578'
  10. }
  11. ]
  12. */

License

MIT © Daniel Eckermann