UNPKG

vladdress

Version:

Lightweight Street Address Parser Written in TypeScript

16 lines (15 loc) 749 B
"use strict"; exports.__esModule = true; exports.matchesPOBox = exports.parsePOBox = void 0; var poBoxRegex = /(P\.?O\.?|POST\s+OFFICE)\s+(BOX|DRAWER)\s\w+/i; var parsePOBox = function (streetString) { var _a; var line1 = (_a = streetString === null || streetString === void 0 ? void 0 : streetString.match(poBoxRegex)) === null || _a === void 0 ? void 0 : _a[0]; streetString = streetString === null || streetString === void 0 ? void 0 : streetString.replace(poBoxRegex, '').trim(); // Carve off the first address line return { line1: line1, streetString: streetString }; }; exports.parsePOBox = parsePOBox; var matchesPOBox = function (input) { return !!input && poBoxRegex.test(input); }; exports.matchesPOBox = matchesPOBox;