# zip3

> A dictionary of 3-digit zip code prefixes mapped to their corresponding metro area

Latest version **1.0.4** (published 2020-06-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install zip3
pnpm add zip3
yarn add zip3
bun add zip3
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-06-30 |
| First published | 2020-06-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 77.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Bill Fienberg |
| Maintainers | billfienberg |
| Keywords | zip code, metro area, metropolitan statistical area |

## Links

- npm: https://www.npmjs.com/package/zip3
- Repository: https://github.com/billfienberg/zip3
- Issues: https://github.com/billfienberg/zip3/issues
- npm.io page: https://npm.io/package/zip3

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.4 (latest) — 2020-06-30
- 1.0.3 — 2020-06-12
- 1.0.2 — 2020-06-12
- 1.0.1 — 2020-06-12
- 1.0.0 — 2020-06-12

## README

# zip3

## Background

Using the first three digits of a US zip code, you can roughly approximate which metropolitan area that zip code is associated with.

## Demo

![zip3 gif](https://raw.githubusercontent.com/billfienberg/zip3/61fc975d14cf37eb0efe812bcb27028f53b2f706/zip3-demo.gif)

Code Sandbox: https://codesandbox.io/s/zip3-demo-rj8oc

## Data

https://en.wikipedia.org/wiki/List_of_ZIP_Code_prefixes

## High Level Design

This package exports a dictionary where the keys are the three-digit zip code prefixes, and the values are objects containing `id` (the three-digit zip), `city`, and `state` (if available).

For example:

```js
{
  "440": { "id": "440", "city": "Cleveland", "state": "OH" }
}
```

## Usage

```js
import { useState } from "react"
import zips from "zip3"

function MetroParser() {
  const [zip, setZip] = useState("90210")
  const shortenedZip = zip.slice(0, 3)
  const metroObject = zips[shortenedZip] || {}
  const { city, state } = metroObject
  const metroString = city && state ? `${city}, ${state}` : ""

  return (
    <div>
      <label>
        Zip code:
        <input
          type="number"
          placeholder="44114"
          value={zip}
          onChange={(e) => {
            const { value } = e.target
            setZip(value)
          }}
        ></input>
      </label>
      <p>Metro: {metroString}</p>
    </div>
  )
}
```

---
_Source: https://npm.io/package/zip3 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
