npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

country-code-flag-phone-extension-json

v1.0.2

Published

Javascript and JSON for Country code flag phone extension

Downloads

156

Readme

Country Detail

Purpose to provide SVG Flags, Unicode flag (emojis), Country code, Phone extension

Install using npm

npm i country-code-flag-phone-extension-json

Methods & Options

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

// Get all countries.
country.all();


const options  = {
    filter: "", // If pass as string then full text search on db (name, subregion, region, currency)
    filter: [], // if pass as array filter by ISO2 codes 
    keys: [], // define object keys to minify records,
    sortBy: [], // sort by priortiy of mentioned ISO2 code.
    limit: 5 // limit the returned object
}

Usage

Get all Countries

List all the countries with details object

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

country.all();

// Return all the country with full detailed object

Filter Countries by ISO2 Code

Filter country by country codes

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

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

// Return only two records filter by India and United States

Filter Countries by plain text search

Quick search in database

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

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

// Return only one records filter search by india
// It search on name, region, subregion, currency name

Sort by Country

In some case, we want specific country to be on top of the dropdown and followed by all others.

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

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

// Return all countried sort by US, IN and
// all remaining countries ..

Limit the record by Country

Top 5 records

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

country.all({
    limit: 5
})
// Return top 5 countries from DB

country.all({
    limit: 5,
    sortBy: ["US", "IN"]
})
// Return top 5 followed by - US, IN
// and reminaing 3 countries from DB

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

// Return  5 records followed by - US, IN
// and reminaing 3 filtered (AD, YE, ZW) countries from DB

Minified the filted object or all countried from DV

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

country.all({
    keys: ["id", "name", "dail_code", "mask", "emoji", "translations.kr"],
    limit: 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": "아메리칸사모아"
            }
        }
    ],
    "count": 5
}
*/

country.all({
    limit: 5,
    sortBy: ["US", "IN"]
})
// Return top 5 followed by - US, IN
// and reminaing 3 countries from DB

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

// Return  5 records followed by - US, IN
// and reminaing 3 filtered (AD, YE, ZW) countries from DB

If you like it

You can buy me coffee https://www.buymeacoffee.com/mayankjhawar

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

License

MIT