Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    node-worldpublic

    node-world

    NPM

    Utility to work with countries data.

    Features

    • European countries (for now)
    • 4 languages for countries localized name (french, english, dutch and german)

    Future

    • Add web interface to manage countries data
    • Add more countries
    • Add more languages
    • Add more data about each countries

    Feel free to contribute.

    Installation

    $ npm install node-world

    Quick Start

    Load in the module

    var World = require('node-world');

    Retrieve country object

    You can find a country by code, ISO 3166-1-alpha-2 or ISO 3166-1-alpha-3, and by name.

    var country = World.findCountryByCode('SP'); // ISO 3166-1-alpha-2 
    var country = World.findCountryByCode('ESP'); // ISO 3166-1-alpha-3 
     
    var country = World.findCountryByName('Spain'); // Country name 

    Country methods

    • getAlpha2Code() : Retrieve ISO 3166-1-alpha-2.
    SP
    • getAlpha3Code() : Retrieve ISO 3166-1-alpha-3.
    ESP
    • getCodes() : Retrieve a JSON object which contains the 2 alpha codes.
    {
        "alpha_2_code": "ES",
        "alpha_3_code": "ESP"
    }
    • getName() : Retrieve international country name.
    Spain
    • getLocalizedNames() : Retrieve localized names.
    {
        "fr": "Espagne",
        "en": "Spain",
        "de": "Spanien",
        "nl": "Spanje"
    }
    • getLocalizedNameIn( language ) : Retrieve a localized name by language. If the localized name does not exist this method will return the international country name.
    Spain

    Tests

    $ npm run-script be-data

    Keywords

    none

    install

    npm i node-world

    Downloadslast 7 days

    0

    version

    0.1.1

    license

    none

    repository

    bitbucket.org

    last publish

    collaborators

    • avatar