Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

countrycodejs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

countrycodejs

Country code validation

  • 0.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

countrycode.js

A work in progress dependency less package to get all countries with it's ISO 3166 code and dialcode or to get a country's name by it's dialcode or ISO 3166 code.

Usage

npm install countrycodejs
const countryCode = require('countrycodejs');

// returns all countries as an array
countryCode.getAllCountries()

// return a country in an object or null if it was not found
countryCode.getCountry.byISOCode('HU')
// {
//   "name": "Hungary",
//   "dial_code": "+36",
//   "code": "HU",
//   "timezones": [
//     "Europe/Budapest"
//   ],
//   "latlng": [
//     47,
//     20
//   ],
//   "capital": "Budapest"
// }

// return a country in an object or null if it was not found
countryCode.getCountry.byDialCode('+36')
// {
//   "name": "Hungary",
//   "dial_code": "+36",
//   "code": "HU",
//   "timezones": [
//     "Europe/Budapest"
//   ],
//   "latlng": [
//     47,
//     20
//   ],
//   "capital": "Budapest"
// }

// return a country in an object or null if it was not found
countryCode.getCountry.byName('Hungary')
// {
//   "name": "Hungary",
//   "dial_code": "+36",
//   "code": "HU",
//   "timezones": [
//     "Europe/Budapest"
//   ],
//   "latlng": [
//     47,
//     20
//   ],
//   "capital": "Budapest"
// }

// return a country in an object or null if it was not found
countryCode.getCountry.byCapital('Budapest')
// {
//   "name": "Hungary",
//   "dial_code": "+36",
//   "code": "HU",
//   "timezones": [
//     "Europe/Budapest"
//   ],
//   "latlng": [
//     47,
//     20
//   ],
//   "capital": "Budapest"
// }

Author

👤 Kristof Ivancza

  • Github: @kHRISl33t

Keywords

FAQs

Package last updated on 18 Feb 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc