@bodhiveggie/countries

0.0.5 • Public • Published

@bodhiveggie/countries

Provides countries' locales, names, dial codes

NPM Version

Install

npm i -S @bodhiveggie/countries

Usage

Get countries info

import countries from '@bodhiveggie/countries/resources/countries.json';
// returns

/**
 * [
 *   {
 *     "name": "China (中国)",
 *     "iso2": "cn",
 *     "dialCode": "86",
 *     "priority": 0,
 *     "areaCodes": null
 *   }
 *   ...
 * ]
 */

Get country's flag image

const flag = require('@bodhiveggie/countries/resources/flags/us.png');

Get country's locale from iso2

NOTE: the locales used here were borrowed from validator pkg. Will default to 'en-US' if no locale was found for specified iso2

import { getLocale } from '@bodhiveggie/countries';

getLocale('us');
// => 'en-US'

Get All locales

import { getAllLocales } from '@bodhiveggie/countries';

Get All ISO2 country codes

import { getAllIso2 } from '@bodhiveggie/countries';

getAllIso2();
// => ['US', 'CN', 'JP' ... ]

Get All Flags Images

import { getFlagImages } from '@bodhiveggie/countries';

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @bodhiveggie/countries

Weekly Downloads

2

Version

0.0.5

License

MIT

Unpacked Size

1.84 MB

Total Files

248

Last publish

Collaborators

  • huhuaishun