Giter Club home page Giter Club logo

iso-3166-2.js's Introduction

iso-3166-2.js

NPM version Build Status Download Count

Lookup information about ISO-3166-2 subdivisions.

Country code format

The country codes in the data are in the ISO 3166-1 alpha 2 format (US, SE ...), but there is a conversion table that makes possible to input alpha 3 codes (USA, SWE ...) to the subdivision and country functions.

https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3

Examples

> iso3166.subdivision("SE-O");

{ type: 'County',
  name: 'Västra Götalands län',
  countryName: 'Sweden',
  countryCode: 'SE',
  regionCode: 'O',
  code: 'SE-O' }
> iso3166.subdivision("UN-1");
null
> iso3166.subdivision("SE", "O");

{ type: 'County',
  name: 'Västra Götalands län',
  countryName: 'Sweden',
  countryCode: 'SE',
  regionCode: 'O',
  code: 'SE-O' }
> iso3166.subdivision("USA", "Indiana");

{ type: 'state',
  name: 'Indiana',
  countryName: 'United States',
  countryCode: 'US',
  regionCode: 'IN',
  code: 'US-IN' }
> iso3166.country("Sweden");
{ name: 'Sweden',
  sub:
   { 'SE-O': { type: 'County', name: 'Västra Götalands län' },
     'SE-N': { type: 'County', name: 'Hallands län' },
     'SE-M': { type: 'County', name: 'Skåne län' },
     'SE-K': { type: 'County', name: 'Blekinge län' },
     'SE-I': { type: 'County', name: 'Gotlands län' },
     'SE-H': { type: 'County', name: 'Kalmar län' },
     'SE-G': { type: 'County', name: 'Kronobergs län' },
     'SE-F': { type: 'County', name: 'Jönköpings län' },
     'SE-E': { type: 'County', name: 'Östergötlands län' },
     'SE-D': { type: 'County', name: 'Södermanlands län' },
     'SE-C': { type: 'County', name: 'Uppsala län' },
     'SE-W': { type: 'County', name: 'Dalarnas län' },
     'SE-Z': { type: 'County', name: 'Jämtlands län' },
     'SE-Y': { type: 'County', name: 'Västernorrlands län' },
     'SE-X': { type: 'County', name: 'Gävleborgs län' },
     'SE-AC': { type: 'County', name: 'Västerbottens län' },
     'SE-AB': { type: 'County', name: 'Stockholms län' },
     'SE-BD': { type: 'County', name: 'Norrbottens län' },
     'SE-T': { type: 'County', name: 'Örebro län' },
     'SE-S': { type: 'County', name: 'Värmlands län' },
     'SE-U': { type: 'County', name: 'Västmanlands län' } },
  code: 'SE' }
> iso3166.country("United Nations");
null

Functions

iso3166.subdivision(code)

Retrieves a subdivision by its full code, ex "SE-O", "US-IN". Returns null if not found.


iso3166.subdivision(country code, subdivision code)

Retrieves a subdivision by its country code and subdivision code, ex ("SWE", "O"). Returns null if not found.


iso3166.subdivision(country code, subdivision name)

Retrieves a subdivision by its country code and subdivision name, ex ("US", "Indiana"). Returns null if not found.


iso3166.country(country code)

Retrieves a country by its code, ex "US", "SE", "SWE". Returns null if not found.


iso3166.country(country name)

Retrieves a country by its name, ex "United States", "Sweden". Returns null if not found.


iso3166.data

The raw ISO 3166-2 data, the layout is:

{
  country code (alpha 2): {
    name: country name, ex Sweden, United States ...
    sub: {
      subdivision code: {
        type: subdivision type, ex county, divison ...
        name: subdivision name, ex Västra Götaland, Indiana
      }
    }
  }
}

iso3166.codes

The ISO 3166-1 alpha 3 to alpha 2 conversion table, the layout is:

{
  country code (alpha 3): country code (alpha 2)
}

Contributors

  • Ola Holmström (@olahol)
  • Ben Ilegbodu (@benmvp)
  • David García (@davidgf)
  • lhchavez (@lhchavez)
  • Peter Pinch (@pdpinch)

iso-3166-2.js's People

Contributors

benmvp avatar lhchavez avatar pdpinch avatar zmoshansky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.