This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 15k traffic Daily!!!

Country Phone Extension Search Javascript package.


Function to supply SVG Flags, Unicode flag (emojis), Nation code, Telephone extension



Set up utilizing npm

npm i country-code-flag-phone-extension-json
Enter fullscreen mode

Exit fullscreen mode



Strategies & Choices

const nation = require("country-code-flag-phone-extension-json");

// Get all nations.
nation.all();


const choices  = {
    filter: "", // If move as string then full textual content search on db (title, subregion, area, forex)
    filter: [], // if move as array filter by ISO2 codes 
    keys: [], // outline object keys to minify data,
    sortBy: [], // type by priortiy of talked about ISO2 code.
    restrict: 5 // restrict the returned object
}
Enter fullscreen mode

Exit fullscreen mode



Utilization



Get all International locations

Checklist all of the nations with particulars object

const nation = require("country-code-flag-phone-extension-json");

nation.all();

// Return all of the nation with full detailed object
Enter fullscreen mode

Exit fullscreen mode



Filter International locations by ISO2 Code

Filter nation by nation codes

const nation = require("country-code-flag-phone-extension-json");

nation.all({
  filter: ["IN", "US"],
});

// Return solely two data filter by India and United States
Enter fullscreen mode

Exit fullscreen mode



Filter International locations by plain textual content search

Fast search in database

const nation = require("country-code-flag-phone-extension-json");

nation.all({
  filter: "india",
});

// Return just one data filter search by india
// It search on title, area, subregion, forex title
Enter fullscreen mode

Exit fullscreen mode



Type by Nation

In some case, we would like particular nation to be on high of the dropdown and adopted by all others.

const nation = require("country-code-flag-phone-extension-json");

nation.all({
  sortBy: ["US", "IN"],
});

// Return all countried type by US, IN and
// all remaining nations ..
Enter fullscreen mode

Exit fullscreen mode



Restrict the file by Nation

Prime 5 data

const nation = require("country-code-flag-phone-extension-json");

nation.all({
    restrict: 5
})
// Return high 5 nations from DB

nation.all({
    restrict: 5,
    sortBy: ["US", "IN"]
})
// Return high 5 adopted by - US, IN
// and reminaing 3 nations from DB

nation.all({
    filter: ["IN", "US", "ZW", "YE", "AD"]
    restrict: 5,
    sortBy: ["US", "IN"]
})

// Return  5 data adopted by - US, IN
// and reminaing 3 filtered (AD, YE, ZW) nations from DB

Enter fullscreen mode

Exit fullscreen mode



Minified the filted object or all countried from DV

const nation = require("country-code-flag-phone-extension-json");

nation.all({
    keys: ["id", "name", "dail_code", "mask", "emoji", "translations.kr"],
    restrict: 5
})
// output
/*
{
    "rows": [
        {
            "id": 1,
            "name": "Afghanistan",
            "dail_code": "+93",
            "mask": "+93-##-###-####",
            "emoji": "πŸ‡¦πŸ‡«",
            "translations": {
                "kr": "μ•„ν”„κ°€λ‹ˆμŠ€νƒ„"
            }
        },
        {
            "id": 2,
            "name": "Aland Islands",
            "dail_code": "+358",
            "emoji": "πŸ‡¦πŸ‡½",
            "translations": {
                "kr": "μ˜¬λž€λ“œ μ œλ„"
            }
        },
        {
            "id": 3,
            "name": "Albania",
            "dail_code": "+355",
            "mask": "+355(###)###-###",
            "emoji": "πŸ‡¦πŸ‡±",
            "translations": {
                "kr": "μ•Œλ°”λ‹ˆμ•„"
            }
        },
        {
            "id": 4,
            "name": "Algeria",
            "dail_code": "+213",
            "mask": "+213-##-###-####",
            "emoji": "πŸ‡©πŸ‡Ώ",
            "translations": {
                "kr": "μ•Œμ œλ¦¬"
            }
        },
        {
            "id": 5,
            "name": "American Samoa",
            "dail_code": "+1684",
            "mask": "+1(684)###-####",
            "emoji": "πŸ‡¦πŸ‡Έ",
            "translations": {
                "kr": "아메리칸사λͺ¨μ•„"
            }
        }
    ],
    "depend": 5
}
*/

nation.all({
    restrict: 5,
    sortBy: ["US", "IN"]
})
// Return high 5 adopted by - US, IN
// and reminaing 3 nations from DB

nation.all({
    filter: ["IN", "US", "ZW", "YE", "AD"]
    restrict: 5,
    sortBy: ["US", "IN"]
})

// Return  5 data adopted by - US, IN
// and reminaing 3 filtered (AD, YE, ZW) nations from DB

Enter fullscreen mode

Exit fullscreen mode



In case you prefer it

You should purchase me espresso
https://www.buymeacoffee.com/mayankjhawar

Assist me at Patreon
https://patreon.com/mayank120



License

MIT

The Article was Inspired from tech community site.
Contact us if this is inspired from your article and we will give you credit for it for serving the community.

This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 10k Tech related traffic daily !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?