zipcodes-usa
v1.1.2
Published
Generate a random US zipcode
Downloads
482
Readme
zipcodes-usa
Generate random identity with a valid standard (not P.O. Box or APO) zip code.
Rationale
This package was developed specifically for testing an e-commerce system that requires a valid US zip code for shipping cost calculation. Invalid zip codes, or those designated for Post Office Boxes (or APO) caused unexpected test failures.
Zip code data for this package originated from the US Government.
Other random identity information (name, street address, phone number, email address) is generated from faker
Install
Installation is simple and straightforward:
npm install --save zipcodes-usa
Usage
var zipcodes-usa = require('zipcodes-usa')
zipcodes-usa.random()
// => JSON object with {name, address, city, state, zip, phone, email}
License
This project is licensed under the MIT License
Notes
Added the ability to pull an address from google geocoding: zipcodes-usa.google() It's still experimental, but appears to be working well. It requires a Google API Key to work, you can obtain one here and set it up as local environment variable GOOGLE_KEY
This is an async function, so usage looks like this:
var zips = require('zicodes-usa')
zips.google().then((data) => {
console.log(data);
});
// -> {"name": xxxx, "address": xxxx, "city": xxxx, "state": XX, "zipcode": xxxx, "phone": xxxx, "email": xxxx, "company": xxxx}
Future work
In the next iteration, I would like to add:
- Option to specify state (and/or city)
- Option to specify zip code type (standard, PO Box, APO)
Contributing
Pull requests and stars are always welcome
For bugs and feature requests, please create an issue