Socket
Socket
Sign inDemoInstall

typed-countries

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

10

package.json
{
"name": "typed-countries",
"version": "1.0.0",
"version": "1.0.1",
"description": "An array of the world's countries, complete with full TypeScript declaration support.",

@@ -10,2 +10,10 @@ "main": "dist/index.js",

"license": "MIT",
"keywords": [
"country",
"countries",
"iso",
"geoip",
"postal codes",
"zip codes"
],
"scripts": {

@@ -12,0 +20,0 @@ "prepublish": "npm run build",

@@ -16,3 +16,3 @@ # typed-countries

## Usage
## Importing

@@ -37,2 +37,36 @@ You can import the package with ES6-style imports, or through Node's require:

const countries = require("typed-countries").default;
```
## Usage
The export is an array of country objects, which means you can use all of the usual array operations on the country list:
```js
import { countries } from "typed-countries";
const usa = countries.find(c => c.iso === "US");
console.log(usa);
// {
// iso: 'US',
// name: 'United States',
// hasPostalCodes: true,
// states: [
// {
// iso: 'AL',
// name: 'Alabama'
// },
// ...
// ],
// zipRegex: "^\\d{5}([\\-]\\d{4})?$"
// }
```
If you're using TypeScript, you can also import the Country and State interfaces:
```js
import { countries, Country, State } from "typed-countries";
const usa: Country = countries.find(c => c.iso === "US");
const iowa: State = usa.states.find(c => c.iso === "IA");
```
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