Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dad-tool

Justintime50143MIT5.0.0

Dummy Address Data (DAD) - Retrieve real addresses from all around the world.

dummy, address, data, dad

readme

Dummy Address Data (DAD) Node Library

Dummy Address Data (DAD) - Retrieve real addresses from all around the world.

Build Status Coverage Status NPM Licence

Showcase

The DAD Node library is the perfect companion to quickly bootstrap address data in your application. DAD provides real addresses from all over the world with a consistent data structure so you can spend less time looking up addresses and address rules and more time coding. Rigorously tested with 2000+ tests, rest easy knowing your address data is uniform, accurate, and performant.

Install

# Install globally for CLI implementation
npm i -g dad-tool

# Install locally for package implementation
npm i dad-tool

Address Data

Address objects will look like the sample below. The data type of each field on an address object is a string. A list of addresses is an array of json objects.

Attempts have been made to verify addresses and ensure that street1, city, state, and zip are present on all records. Some lists may be shorter than others to avoid complexity or because of a lack of accurate data.

The following files can be found in the data directory.

Australia

Locations Tag
Victoria Area AU_VT

Canada

Locations Tag
BC Area CA_BC

China

Locations Tag
Beijing Area CN_BJ
Hong Kong - Wan Chai Area CN_HK

Europe

Locations Tag
Germany - Wesel Area EU_DE
Spain - Countrywide EU_ES
France - Paris Area EU_FR
United Kingdom - England Area EU_UK

Mexico

Locations Tag
Mexico - Mexico City Area MX_MX

United States

Locations Tag
Arizona - Gilbert Area US_AZ
California - Anaheim Area US_CA
Idaho - Boise Area US_ID
Kansas - Barton County US_KS
Nevada - Lincoln Area US_NV
New York - Rochester Area US_NY
Oregon - Portland Area US_OR
Texas - Austin Area US_TX
Utah - Provo Area US_UT
Washington - Spokane Area US_WA

Usage

CLI Implementation

# Returns a random address from a list to console
dad US_UT

Package Implementation

const dad = require('dad-tool');

// Grab a random UT address
const address = dad.random('US_UT');
console.log(address);

// Alternatively, grab the entire UT list
const addresses = dad.list('US_UT');
console.log(addresses);

// Print to console or do whatever you'd like with the address data
console.log(address.city);

// Get the list of all ISO country codes
const isoData = dad.isoCountryCodes();
for (let i = 0; i < isoData.length; i++) {
  console.log(JSON.stringify(isoData[i], null, 4));
}

Sample Address Object

A sample address object will look like the following:

{
  "street1": "231 N 1200 W",
  "street2": "UNIT 104",
  "city": "OREM",
  "state": "UT",
  "zip": "84057",
  "country": "US"
}

Sample ISO Country Object

{
  "country": "United States of America",
  "alpha_2_code": "US",
  "alpha_3_code": "USA"
}

Development

# Lint the project
npm run lint

# Run tests
npm run test

# Run test coverage
npm run coverage

# Update the DAD data files
git submodule init && git submodule update --remote dad

Attribution

  • Addresses provided by DAD.

changelog

CHANGELOG

v5.0.0 (2024-07-16)

  • Drops support for Node < 16
  • Adds support for Node 20, 22
  • Bumps dependencies

v4.2.0 (2022-02-05)

  • Adds French addresses
  • Bumps dev dependencies

v4.1.0 (2021-08-02)

  • Swaps the manually downloaded DAD data to a git submodule for easier management moving forward
  • Reworks the entire data-router from a switch/case statement to an object literal for easier management. Refactored the order of logic and changed all variable names for easier readability
  • Tags will not automatically be capatilized when passed as parameters to assist in capitilization input errors
  • Bumps dependencies

v4.0.0 (2021-07-12)

  • Separates DAD address data into a separate repo (https://github.com/justintime50/dad), removes tooling and references to data and focuses instead on implementing a way to retrieve that data via Node
  • Removed the addresses key as inherently each list is a set of addresses already
  • Bumped dependencies, additional small tweaks

v3.1.0 (2021-05-26)

  • Drops support for Node 10 and pins Node 12 as the minimum version
  • Bumps dependencies
  • Tests against Node 16

v3.0.0 (2021-01-31)

  • Adds CLI implementation so you can retrieve addresses right on the command line
  • Adds support for ISO country codes, now you can retrieve the 2 and 3 letter country codes for each country
  • Adds Mexico addresses
  • Switches Travis CI for GitHub Actions
  • Various small tweaks and improvements

v2.6.0 (2020-11-25)

  • Shifted logic around, renamed files and lists, updated documentation, consolidated all US data into a single folder
  • Added Idaho to US_ID and Arizona to US_AZ
  • Completely re-wrote the create-slim-json utility. It now requires much less manual work, accepts more configuration options, and runs much faster while being more reliable

v2.5.0 (2020-10-21)

  • Overhauled testing framework
    • Introduced chai for better assert and expect
    • Went from ~50 tests to ~1700 tests by iterating each record
    • Added tests to ensure the data structure of each record was uniform by asserting keys were the same across every record - corrected a few records with bad keys

v2.4.0 (2020-10-21)

  • Added China - Honk Kong addresses

v2.3.2 (2020-08-15)

  • Switched coverage reporting commands and packages (switched istanbul to nyc)

v2.3.1 (2020-08-15)

  • Added more unit tests (100% coverage!)
  • Errors are now properly thrown instead of printing

v2.3.0 (2020-08-14)

  • Added unit tests
  • Added coveralls test coverage
  • Added automated publishing workflow via Travis/tags

v2.2.1 (2020-05-01)

  • Fixed UK reference in data-router

v2.2.0 (2020-04-30)

  • Bug fixes
  • Reference adjustments for GB -> UK addresses
  • Updated docs to match changes and clarified state/area locations

v2.1.1 (2020-04-03)

  • Changed if/else statements for switch/case statements to better handle the large variable set
  • Fixed address references introduced in v2.1.0
  • Added better error handling surrounding invalid tags being passed

v2.1.0 (2020-04-02)

  • Added us-northeast, us-midwest, and us-south addresses
  • Added Germany addresses
  • Added Spain addresses

v2.0.1 (2020-04-01)

  • Corrected a few lingering zip codes that were integers instead of strings
  • Corrected Australia country on each record
  • Corrected README
  • Replaced each GB address with a real one including valid zips
  • Added 4 more China addresses to match the size of the other smaller lists

v2.0.0 (2020-03-31)

  • Added country to each address
  • Validated addresses and corrected inaccurate items
  • Made all entries strings to keep records uniform (breaking change)
  • Changed all country codes to allow for tag reuse among international addresses - eg: CA = California, CA = Canada (breaking change)
  • Added Australia, Canada, China, and Europian addresses

v1.0.2 (2020-03-30)

  • Bug fixes and docs updates
  • Added Travis CI testing

v1.0.0 (2020-03-30)

  • Initial release
  • Pull a random UT address from a list of 100