This is a Node.js package that allows you to search for countries using different criteria such as country code, dial code, flag, or country name. It exports several functions that can be used in your Node.js projects to retrieve country data.
To use this package, you can install it from npm using the following command:
npm install country-seeker
To use this package, you first need to import it into your project:
import { getCountries, useCountry, useDialCode, useFlag, useCountryName, useCountryCode } from "country-seeker";
This function returns an array of all the countries in the package's data:
const countries = getCountries();
console.log(countries);
This function takes an object with two properties, type and value, and returns the first country that matches the given criteria:
const countryByCode = useCountry({ type: 'code', value: 'US' });
console.log(countryByCode);
const countryByDialCode = useCountry({ type: 'dial_code', value: '+1' });
console.log(countryByDialCode);
const countryByFlag = useCountry({ type: 'flag', value: '🇺🇸' });
console.log(countryByFlag);
const countryByName = useCountry({ type: 'name', value: 'United States' });
console.log(countryByName);
This function takes a value parameter, which represents the dial code of the country, and returns the first country that matches the given dial code:
const country = useDialCode({ value: '+1' });
console.log(country);
This function takes a value parameter, which represents the flag of the country, and returns the first country that matches the given flag:
const country = useFlag({ value: '🇺🇸' });
console.log(country);
This function takes a value parameter, which represents the name of the country, and returns the first country that matches the given name::
const country = useCountryName({ value: 'United States' });
console.log(country);
This function takes a value parameter, which represents the code of the country, and returns the first country that matches the given code:
const country = useCountryCode({ value: 'US' });
console.log(country);
If you find a bug or have a feature request, please open an issue on the GitHub repository . Pull requests are also welcome. .