Socket
Socket
Sign inDemoInstall

@basementuniverse/country-code-location

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @basementuniverse/country-code-location

Convert between 2-digit country codes and locations


Version published
Maintainers
1
Install size
31.7 kB
Created

Readme

Source

Country Code Locations

Convert country codes into locations, or locations into the closest country code.

Country codes are ISO 3166-1 alpha-2 (2 digit) country codes.

Locations are defined using latitude and longitude and represent a roughly-central location for each country.

Installation

npm install @basementuniverse/country-code-location

How to use

Import the package:

import {
  countryCodeToLocation,
  locationToCountryCode
} from '@basementuniverse/country-code-location';

Convert a country code into a location:

const australiaLocation = countryCodeToLocation('AU');
{
  "country": "Australia",
  "code": "AU",
  "lat": -27,
  "long": 133
}

Find the country closest to a location:

const closestToLocation = locationToCountryCode(47, -1);
{
  "country": "France",
  "code": "FR",
  "lat": 46,
  "long": 2
}

Keywords

FAQs

Last updated on 18 May 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