1.1.0 • Published 2 years ago

js-countrydata v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

js-countrydata

A utility library that provides country codes, name, flags and currency.

Installation

# with npm
npm install js-countrydata

# with yarn
yarn add js-countrydata

Usage

import { getAllCountries, getSpecificCountry, getSpecifiedCountries } from "js-countrydata";

const countries = getAllCountries(); // returns [{ name: "Algeria", flag: "🇩🇿", code: "DZ", dial_code: "+213" }, ...]
const specificCountry = getSpecificCountry({type: "code", value: "ID"}, ["name", "flag"]) // returns { name: "Indonesia", flag: "🇮🇩" }
const specifiedCountries = getSpecifiedCountries([{type: "code", value: "ID"}, {type: "dial_code", value: "+250"}], ["name", "flag"]) // returns [{name: 'Indonesia', flag: '🇮🇩'}, {name: 'Rwanda', flag: '🇷🇼'}]

Arguments

The method accept optional arguments that are specific to this method.

Argumenttypedefaultnotes
filtersarray"name","flag","code","dial_code"Contains an array of keys that should be returned
queryobjectnoneRequired when invoking getSpecificCountry and getSpecifiedCountries methods

License

MIT

1.1.0

2 years ago

1.0.0

2 years ago