1.0.12 • Published 2 years ago

houski-address-parser v1.0.12

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

houski-address-parser

This package standardizes Canadian postal addresses.

Does it work for all of them? Probably not. Does it work for most of them? ... probably. 🤷

How to install

In your node project:

const houskiAddressParser = require("houski-address-parser");

import houskiAddressParser from "houski-address-parser"

How to use

Simply run the function on an address string:

houskiAddressParser("7333 37 AV NW t2c3n4 51st street Ottawa-Gatineau, Ontario, canada")

That should give the resulting object of:

{
    city: "Ottawa-Gatineau",
    full: "7333 37 Avenue NW 51st Street Ottawa-Gatineau Ontario",
    fullWithCountry:
      "7333 37 Avenue NW 51st Street Ottawa-Gatineau Ontario Canada",
    key: "733337avenw51stst",
    long: "7333 37 Avenue NW 51st Street",
    postalCode: "T2C3N4",
    province: "Ontario",
    short: "7333 37 Ave NW 51st St",
  }

You can APPEND overiding suffixes to the default suffix set by passing in an array with this structure, and calling the function as shown.

const overrides = [
  {
    long: "PARK",
    abbrs: ["PARK", "PRK", "PA"],
    short: "PA",
  },
  {
    long: "TERRACE",
    abbrs: ["TERRACE", "TC"],
    short: "TC",
  },
  {
    long: "MEWS",
    abbrs: ["MEWS", "ME"],
    short: "ME",
  },
];

houskiAddressParser(
  "7333 37 AV NW t2c3n4 51st street Ottawa-Gatineau, Ontario, canada",
  overrides,
  true // THIS TRUE PARAMETER IS NEEDED TO APPEND EXTRA SUFFIXES INSTEAD OF ENTIRELY REPLACING THEM.
);

You can REPLACE the entire default suffix set by passing in an array (as shown above) and then calling the function as shown:

houskiAddressParser(
  "7333 37 AV NW t2c3n4 51st street Ottawa-Gatineau, Ontario, canada",
  overrides
);

Check the package's index.test.js file for more examples.

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.12

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago