Coder Social home page Coder Social logo

mulk's Introduction

mulk

npm

Gets the country details by country name, ITU or ISO codes

Installation

You can either install using yarn or using npm

yarn add mulk
npm i mulk

Usage

Import either using require or import

const mulk = require('mulk');

// Get country by country name/itu/ISO2/ISO3
const countryByName = mulk('United Arab Emirates');
const countryByItu = mulk('UAE');
const countryByIso2 = mulk('AE');
const countryByIso3 = mulk('ARE');

// Resulting value for each of the calls above will be the country object
// {
//   "capital": "Islamabad",
//  "continent": "AS",
//  "name": "Pakistan",
//  "officialName": "Pakistan",
//  "distSign": "PK",
//  "dialCode": "92",
//  "edgar": "R0",
//  "fifa": "PAK",
//  "fips": "PK",
//  "gaul": "188",
//  "geoNameId": "1168579",
//  "olympicsId": "PAK",
//  "iso2": "PK",
//  "iso3": "PAK",
//  "currencyCode": "PKR",
//  "currencyCountryName": "PAKISTAN",
//  "currencyMinorUnit": 2,
//  "currencyName": "Pakistan Rupee",
//  "currencyNumericCode": 586,
//  "itu": "PAK",
//  "isIndependent": "Yes",
//  "languages": [
//    "ur-PK",
//    "en-PK",
//    "pa",
//    "sd",
//    "ps",
//    "brh"
//  ],
//  "m49": 586,
//  "marc": "pk",
//  "tld": ".pk",
//  "wmo": "PK"
// }

// Return default value if the country details are not found
const country = mulk('non-existing-country', null, { 
  id: 'non-existing', 
  name: 'Default Country'
});

// Get single field instead of object
const dialCode = mulk('UAE', 'dialCode');

// Get default value for field if does not exist
const dialCode = mulk('UAE', 'dialCode', '000');

Feel free to open an issue if you need help with some specific usecase.

Contributions

  • Report issues with problems and suggestions
  • Open pull request with improvements
  • Spread the word
  • Reach out with any feedback Twitter URL

License

MIT © Muhammad Umar Mehmood

mulk's People

Contributors

w3debugger avatar kamranahmedse avatar

Watchers

James Cloos 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.