Formats a civic address from its pieces based on guidelines from Canada Post for properly addressing mail to Canadian and American addresses.
- 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')
npm install @cityssm/civic-address-format
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"