0.1.0 • Published 1 year ago

@cityssm/civic-address-format v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Civic Address Format

npm (scoped) Codacy Badge Maintainability codecov GitHub Workflow Status

Formats a civic address from its pieces based on guidelines from Canada Post for properly addressing mail to Canadian and American addresses.

Features

  • Typescript support.
  • Places the unit number (when present) before the civic number with a hyphen in between.
  • Uses no space when a single letter qualifier is present (i.e. '123A'), or one space for longer qualifiers (i.e. '123 1/2')

Installation

npm install @cityssm/civic-address-format

Usage

import { formatCivicAddress } from '@cityssm/civic-address-format'

formatCivicAddress({
  civicNumber: '99',
  streetName: 'Foster Dr'
})
// => "99 Foster Dr"

formatCivicAddress({
  civicNumber: '123',
  streetName: 'MAIN ST NW',
  unitNumber: '10',
  qualifier: '1/2'
})
// => "10-123 1/2 MAIN ST NW"