Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "us-zips", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "A list of US ZIP codes and their geolocations", | ||
@@ -19,4 +19,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"ava": "^0.18.2" | ||
"ava": "^0.20.0" | ||
} | ||
} |
@@ -14,2 +14,3 @@ # us-zips | ||
const usZips = require('us-zips') | ||
const somewhere = { | ||
@@ -23,26 +24,84 @@ lat: 33.1234, | ||
If you want to get the nearest ZIP, just use [`blakek/geo2zip`](https://github.com/blakek/geo2zip). | ||
If you want to get the nearest ZIP, see if [`geo2zip`](https://github.com/blakek/geo2zip) fits your needs. | ||
## Data Format | ||
## Data Formats | ||
Returns an object with keys for each ZIP code. The value of each key is an object with lat and lng properties. | ||
### Default (Object) | ||
The default export returns an object. The object's keys are each ZIP code and values are objects with latitude and longitude properties. | ||
```js | ||
const usZips = { | ||
'12345': { | ||
lat: 12.345678, | ||
lng: -87.654321 | ||
const usZips = require('us-zips') | ||
console.log(usZips['54301']) | ||
// { latitude: 44.480778, longitude: -88.016063 } | ||
// Shape | ||
{ | ||
'54301': { | ||
latitude: 44.480778, | ||
longitude: -88.016063 | ||
} | ||
} | ||
``` | ||
### Array | ||
```js | ||
const usZips = require('us-zips/array') | ||
console.log(usZips.find(zip => zip.zipCode === '37214')) | ||
// { latitude: 36.162189, longitude: -86.670867, zipCode: '37214' } | ||
// Shape | ||
[ | ||
... | ||
{ | ||
latitude: 36.162189, | ||
longitude: -86.670867, | ||
zipCode: '37214' | ||
}, | ||
... | ||
} | ||
] | ||
``` | ||
## Install | ||
### Key/value | ||
With [npm](https://npmjs.org/) installed, run | ||
```js | ||
const usZips = require('us-zips/key-value') | ||
console.log(usZips.find(([key, value]) => key === '10001')) | ||
// ['10001', { latitude: 40.750634, longitude: -73.997176 }] | ||
// Shape | ||
[ | ||
... | ||
['10001', { | ||
latitude: 40.750634, | ||
longitude: -73.997176 | ||
}], | ||
... | ||
] | ||
``` | ||
$ npm install --save us-zips | ||
### Map | ||
```js | ||
const usZips = require('us-zips/map') | ||
console.log(usZips.get('90210')) | ||
// { latitude: 34.100517, longitude: -118.41463 } | ||
``` | ||
## Install | ||
With [Yarn](https://yarnpkg.com/en/) or [npm](https://npmjs.org/) installed, run: | ||
```shell | ||
yarn add us-zips | ||
# ...or, if using `npm` | ||
npm install us-zips | ||
``` | ||
## Acknowledgments | ||
@@ -61,2 +120,1 @@ | ||
MIT | ||
@@ -6,3 +6,3 @@ const fs = require('fs') | ||
const outputFile = path.join(__dirname, '../array/index.js') | ||
const outputFile = path.join(__dirname, '../array.js') | ||
@@ -12,11 +12,6 @@ const outputStart = 'module.exports = [\n ' | ||
const outputBody = Object | ||
.keys(usZips) | ||
const outputBody = Object.keys(usZips) | ||
.map(zipCode => JSON.stringify(Object.assign(usZips[zipCode], { zipCode }))) | ||
.join(',\n ') | ||
fs.writeFileSync( | ||
outputFile, | ||
outputStart + outputBody + outputEnd, | ||
'utf8' | ||
) | ||
fs.writeFileSync(outputFile, outputStart + outputBody + outputEnd, 'utf8') |
@@ -6,3 +6,3 @@ const fs = require('fs') | ||
const outputFile = path.join(__dirname, '../key-value/index.js') | ||
const outputFile = path.join(__dirname, '../key-value.js') | ||
@@ -12,11 +12,6 @@ const outputStart = 'module.exports = [\n ' | ||
const outputBody = Object | ||
.keys(usZips) | ||
const outputBody = Object.keys(usZips) | ||
.map(zipCode => JSON.stringify([zipCode, usZips[zipCode]])) | ||
.join(',\n ') | ||
fs.writeFileSync( | ||
outputFile, | ||
outputStart + outputBody + outputEnd, | ||
'utf8' | ||
) | ||
fs.writeFileSync(outputFile, outputStart + outputBody + outputEnd, 'utf8') |
@@ -6,3 +6,3 @@ const fs = require('fs') | ||
const outputFile = path.join(__dirname, '../map/index.js') | ||
const outputFile = path.join(__dirname, '../map.js') | ||
@@ -12,11 +12,6 @@ const outputStart = 'module.exports = new Map([\n ' | ||
const outputBody = Object | ||
.keys(usZips) | ||
const outputBody = Object.keys(usZips) | ||
.map(zipCode => JSON.stringify([zipCode, usZips[zipCode]])) | ||
.join(',\n ') | ||
fs.writeFileSync( | ||
outputFile, | ||
outputStart + outputBody + outputEnd, | ||
'utf8' | ||
) | ||
fs.writeFileSync(outputFile, outputStart + outputBody + outputEnd, 'utf8') |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8187607
118
132670