Socket
Socket
Sign inDemoInstall

iso-country-utils

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    iso-country-utils

A helper to get country codes following the ISO 3316


Version published
Weekly downloads
370
decreased by-48.54%
Maintainers
1
Install size
97.1 kB
Created
Weekly downloads
 

Readme

Source

Welcome to iso-country-utils 👋

NPM version Bundle size MIT

A helper to get country codes following the ISO 3316

Install

npm install iso-country-utils

or

yarn add iso-country-utils

Usage

This is the Country type:

type Country = {
  name: string;
  alpha2: string;
  alpha3: string;
  code: string;
};

You can get all the countries just calling

import { countries } from 'iso-country-utils';

You can get a country by its name with getCountryFromName:

import { getCountryFromName } from 'iso-country-utils';

const US = getCountryFromName('United States of America');

You can get a country by its alpha2 value with getCountryFromAlpha2:

import { getCountryFromAlpha2 } from 'iso-country-utils';

const US = getCountryFromAlpha2('US');

You can get a country by its alpha3 value with getCountryFromAlpha3:

import { getCountryFromAlpha3 } from 'iso-country-utils';

const US = getCountryFromAlpha3('USA');

You can get a country by its code with getCountryFromAlpha3:

import { getCountryFromCode } from 'iso-country-utils';

const US = getCountryFromCode('840');

You can find a full list of countries from the source

Author

👤 Pedro Filho pedro@filho.me

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Buy Me A Coffee

Keywords

FAQs

Last updated on 24 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc