Reference · Parsing, formatting and shared types
parseSecondaryUnitfunction
Takes a secondary unit (apartment, suite, floor and the rest) off a street line.
Import it
import { parseSecondaryUnit } from "@johnmorrisdotca/address-plus";
Definition
function parseSecondaryUnit(text: string): { unit: string | undefined; secUnitType: string | undefined; secUnitNum: string | undefined; remaining: string; }
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The street line. |
Returns
{ unit: string | undefined; secUnitType: string | undefined; secUnitNum: string | undefined; remaining: string; }
The unit as written, its designator in full and its number (each undefined when there is none), and the
text that remains.
Examples
import { parseSecondaryUnit } from "@johnmorrisdotca/address-plus";
console.log(parseSecondaryUnit("123 Main St Apt 4"));
// → {"unit":"Apartment 4","secUnitType":"Apartment","secUnitNum":"4","remaining":"123 Main St"}{
unit: 'Apartment 4',
secUnitType: 'Apartment',
secUnitNum: '4',
remaining: '123 Main St'
}What it prints (run when this page was built)