GithubHelp home page GithubHelp logo

scriptex / typed-usa-states Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 3.0 1.02 MB

An array of geographical data for all USA states with full TypeScript support

Home Page: https://atanas.info/portfolio/open-source/typed-usa-states

License: MIT License

TypeScript 99.85% Shell 0.03% JavaScript 0.12%
usa-states-data geographic-data typescript-definitions geographical-data usa-states

typed-usa-states's Introduction

Travis CI Github Build Codacy Badge Codebeat Badge CodeFactor Badge DeepScan grade Analytics

Typed USA States

An array of geographical data for all USA states with full TypeScript support

Visitor stats

GitHub stars GitHub forks GitHub watchers GitHub followers

Code stats

GitHub code size in bytes GitHub repo size GitHub language count GitHub top language GitHub last commit

Content

This package contains geographical data for all USA states including:

  • name of the state
  • abbreviation of the state
  • territory: whether the state is under the sovereign jurisdiction of the federal government of the United States
  • the capital city of the state
  • contiguous: whether the state shares common borders with other states
  • zipCodes: an array containing string arrays. Each array contains two elements (string) - the start and the end of the zip code range. (The string type is used because TypeScript does not like numbers with leading zero. Pull request are welcome if you find a workaround for this issue.)
  • area: the area of the state in square miles in the following format:
    • year: when was the value last updated
    • value: the actual area
  • population: the population of the state in the following format:
    • year: when was the value last updated
    • count: the actual population
  • counties of the state

NB There is no counties information for the following US overseas territories:

  • American Samoa
  • Northern Mariana Islands
  • Puerto Rico
  • Virgin Islands

If you happen to have any knowledge on the matter, please consider contributing!

Cities

This package provides data for all cities in the US.

You can use this by importing the cities array:

import { usaCities } from 'typed-usa-states';

Each city object contains the following data:

  • name: the name of the city
  • state: the state which the city belongs to

Installation

npm i typed-usa-states

# or

yarn add typed-usa-states

Usage

Since the size of the array is pretty big, you can choose which states data to import in your application.

There are several predefined exported arrays with data for the states.

Their content's schema is explained below:

Import the full states data

import { usaStatesFull } from 'typed-usa-states';

Schema:

{
	name: string,
	abbreviation: string,
	territory: boolean,
	capital: string,
	contiguous: boolean,
	zipCodes: [string, string][],
	area: {
		year: number,
		value: number
	},
	population: {
		year: number,
		count: number
	},
	counties: string[]
}

Import only the required data

import { usaStates } from 'typed-usa-states';

Schema:

{
	name: string,
	abbreviation: string,
	territory: boolean,
	capital: string,
	contiguous: boolean
}

Import the required and area data

import { usaStatesWithArea } from 'typed-usa-states';

Schema:

{
	name: string,
	abbreviation: string,
	territory: boolean,
	capital: string,
	contiguous: boolean,
	area: {
		year: number,
		value: number
	}
}

Import the required and counties data

import { usaStatesWithCounties } from 'typed-usa-states';

Schema:

{
	name: string,
	abbreviation: string,
	territory: boolean,
	capital: string,
	contiguous: boolean,
	counties: string[]
}

Import the requied and population data

import { usaStatesWithPopulation } from 'typed-usa-states';

Schema:

{
	name: string,
	abbreviation: string,
	territory: boolean,
	capital: string,
	contiguous: boolean,
	population: {
		year: number,
		count: number
	}
}

Import the required and zipcode data

import { usaStatesWithZipCodes } from 'typed-usa-states';

Schema:

{
	name: string,
	abbreviation: string,
	territory: boolean,
	capital: string,
	contiguous: boolean,
	zipCodes: [string, string][]
}

Import the cities data

import { usaCities } from 'typed-usa-states';

Schema:

{
	city: string;
	state: string;
}

Usage in browser

You can use the module directly in the browser (without any module bundler such as Webpack or Parcel) but you will need to include requirejs.

The usage is not so straight-forward, so please refer to the demo

Module bundlers

typed-usa-states exposes several pretty large arrays.

It is possible that you experience issues with insufficient memory when using create-react-app or Webpack, Parcel, Rollup, etc. or if you are using the package in Docker or other CI environment.

In this case you might want to import the required array directly instead of relying on the module bunlder to resolve it for you.

This means that you need to change your code like this:

- import { usaStates } from 'typed-usa-states';
+ import { usaStates } from 'typed-usa-states/dist/states';

- import { usaCities } from 'typed-usa-states';
+ import { usaCities } from 'typed-usa-states/dist/cities';

- import { usaStatesFull } from 'typed-usa-states';
+ import { usaStatesFull } from 'typed-usa-states/dist/states-full';

- import { usaStatesWithArea } from 'typed-usa-states';
+ import { usaStatesWithArea } from 'typed-usa-states/dist/states-with-area';

- import { usaStatesWithCounties } from 'typed-usa-states';
+ import { usaStatesWithCounties } from 'typed-usa-states/dist/states-with-counties';

- import { usaStatesWithPopulation } from 'typed-usa-states';
+ import { usaStatesWithPopulation } from 'typed-usa-states/dist/states-with-population';

- import { usaStatesWithZipCodes } from 'typed-usa-states';
+ import { usaStatesWithZipCodes } from 'typed-usa-states/dist/states-with-zipcodes';

Typings

The package exports several types which can be used in TypeScript environment. The typings are located in dist/index.d.ts and are being auto detected by TypeScript.

LICENSE

MIT


Connect with me:

                     

Support and sponsor my work:

typed-usa-states's People

Contributors

alpanayotov avatar dependabot[bot] avatar renovate-bot avatar renovate[bot] avatar scriptex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

typed-usa-states's Issues

Missing zip codes

While I think that this is a great initiative, I think that maintaining an updated and complete list of the US zip codes might be a big effort.

For example: Montgomery, AL 36117 is missing.

Kudos anyway!

Unable to build with webpack after v2

5:29:56 AM: $ react-scripts build
5:29:59 AM: Creating an optimized production build...
5:32:37 AM: 
5:32:37 AM: Treating warnings as errors because process.env.CI = true.
5:32:37 AM: Most CI servers set it automatically.
5:32:37 AM: 
5:32:37 AM: Failed to compile.
5:32:37 AM: 
5:32:37 AM: ./node_modules/typed-usa-states/dist/index.js
5:32:37 AM: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
5:32:37 AM: ./node_modules/typed-usa-states/dist/states.js
5:32:37 AM: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
5:32:37 AM: ./node_modules/typed-usa-states/dist/states-with-zipcodes.js
5:32:37 AM: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
5:32:37 AM: ./node_modules/typed-usa-states/dist/states-with-population.js
5:32:37 AM: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
5:32:37 AM: ./node_modules/typed-usa-states/dist/states-with-counties.js
5:32:37 AM: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
5:32:37 AM: ./node_modules/typed-usa-states/dist/states-with-area.js
5:32:37 AM: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
5:32:37 AM: ./node_modules/typed-usa-states/dist/states-full.js
5:32:37 AM: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
5:32:37 AM: ./node_modules/typed-usa-states/dist/cities.js
5:32:37 AM: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

This repository currently has no open or pending branches.


  • Check this box to trigger a request for Renovate to run again on this repository

Module size

In the README add details about default, minified and gzipped size of the bundle using this module.

Maybe think of a way to split the data in smaller/different bundles. One of them can contain all of the data. The rest can contain only parts of the data.

package.json specifies a `main` module field that could not be resolved

Looks like the published npm package references a "dist" folder that's not part of the included files.

Using v1.1.0 with yarn.

While trying to resolve module `typed-usa-states` from file `/Users/matt/Projects/perfect-measure-mobile-app/src/db/models/address.ts`, the package `/Users/matt/Projects/perfect-measure-mobile-app/node_modules/typed-usa-states/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/matt/Projects/perfect-measure-mobile-app/node_modules/typed-usa-states/dist/index.js`. Indeed, none of these files exist:

  * /Users/matt/Projects/perfect-measure-mobile-app/node_modules/typed-usa-states/dist/index.js(.native|.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)
  * /Users/matt/Projects/perfect-measure-mobile-app/node_modules/typed-usa-states/dist/index.js/index(.native|.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)
Failed building JavaScript bundle.

Some of these aren't states or territories - they're entirely different countries

The following are countries unaffiliated with the United States (via state, incorporated territory, or unincorporated territory) and should be removed. They are part of Compacts of Free Association, but are separate entities entirely, maintaining embassies in the United States. To have them under a list of "typed-usa-states" is extremely misleading.

  • Federated States of Micronesia
  • Marshall Islands
  • Palau

CVE-2021-23343 (Medium) detected in path-parse-1.0.6.tgz

CVE-2021-23343 - Medium Severity Vulnerability

Vulnerable Library - path-parse-1.0.6.tgz

Node.js path.parse() ponyfill

Library home page: https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz

Path to dependency file: typed-usa-states/package.json

Path to vulnerable library: typed-usa-states/node_modules/path-parse

Dependency Hierarchy:

  • tslint-6.1.3.tgz (Root Library)
    • resolve-1.19.0.tgz
      • path-parse-1.0.6.tgz (Vulnerable Library)

Found in HEAD commit: 7dc5dfe91d860c8433d707c9b080d3f40a7abbf6

Vulnerability Details

All versions of package path-parse are vulnerable to Regular Expression Denial of Service (ReDoS) via splitDeviceRe, splitTailRe, and splitPathRe regular expressions. ReDoS exhibits polynomial worst-case time complexity.

Publish Date: 2021-05-04

URL: CVE-2021-23343

CVSS 3 Score Details (5.3)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: Low

For more information on CVSS3 Scores, click here.


Step up your Open Source Security Game with WhiteSource here

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.