From 870ca52b2b6fe6e2e914f558547507661eb72557 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 26 Mar 2022 19:22:56 +0000 Subject: [PATCH] chore(release): set `package.json` to 1.2.0 [skip ci] # [1.2.0](https://github.com/DASPRiD/localized-address-format/compare/v1.1.0...v1.2.0) (2022-03-26) ### Features * rewrite library, update address formats, use newer dev dependencies and utilize GitHub actions ([81f482e](https://github.com/DASPRiD/localized-address-format/commit/81f482e0504049a4de9459f05946ad9add5c57e9)) --- CHANGELOG.md | 6 + dist/addressFormats.d.ts | 3 + dist/formatAddress.d.ts | 13 ++ dist/index.cjs.js | 344 ++++++++++++++++++++++++++++++++++++++ dist/index.cjs.js.map | 1 + dist/index.d.ts | 2 + dist/index.esm.js | 340 +++++++++++++++++++++++++++++++++++++ dist/index.esm.js.map | 1 + dist/index.umd.js | 350 +++++++++++++++++++++++++++++++++++++++ dist/index.umd.js.map | 1 + 10 files changed, 1061 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 dist/addressFormats.d.ts create mode 100644 dist/formatAddress.d.ts create mode 100644 dist/index.cjs.js create mode 100644 dist/index.cjs.js.map create mode 100644 dist/index.d.ts create mode 100644 dist/index.esm.js create mode 100644 dist/index.esm.js.map create mode 100644 dist/index.umd.js create mode 100644 dist/index.umd.js.map diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3dce55a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# [1.2.0](https://github.com/DASPRiD/localized-address-format/compare/v1.1.0...v1.2.0) (2022-03-26) + + +### Features + +* rewrite library, update address formats, use newer dev dependencies and utilize GitHub actions ([81f482e](https://github.com/DASPRiD/localized-address-format/commit/81f482e0504049a4de9459f05946ad9add5c57e9)) diff --git a/dist/addressFormats.d.ts b/dist/addressFormats.d.ts new file mode 100644 index 0000000..30c9477 --- /dev/null +++ b/dist/addressFormats.d.ts @@ -0,0 +1,3 @@ +declare const addressFormats: Map; +export declare const defaultAddressFormat = "%N%n%O%n%A%n%C"; +export default addressFormats; diff --git a/dist/formatAddress.d.ts b/dist/formatAddress.d.ts new file mode 100644 index 0000000..db33ed2 --- /dev/null +++ b/dist/formatAddress.d.ts @@ -0,0 +1,13 @@ +export declare type Address = { + postalCountry?: string; + administrativeArea?: string; + locality?: string; + dependentLocality?: string; + postalCode?: string; + sortingCode?: string; + organization?: string; + name?: string; + addressLines?: string[]; +}; +declare const formatAddress: (address: Address) => string[]; +export default formatAddress; diff --git a/dist/index.cjs.js b/dist/index.cjs.js new file mode 100644 index 0000000..c5cf7f3 --- /dev/null +++ b/dist/index.cjs.js @@ -0,0 +1,344 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +// This file is auto-generated via "npm run update-formats". Do not alter manually! +const addressFormats = new Map([ + ['AC', '%N%n%O%n%A%n%C%n%Z'], + ['AD', '%N%n%O%n%A%n%Z %C'], + ['AE', '%N%n%O%n%A%n%S'], + ['AF', '%N%n%O%n%A%n%C%n%Z'], + ['AI', '%N%n%O%n%A%n%C%n%Z'], + ['AL', '%N%n%O%n%A%n%Z%n%C'], + ['AM', '%N%n%O%n%A%n%Z%n%C%n%S'], + ['AR', '%N%n%O%n%A%n%Z %C%n%S'], + ['AS', '%N%n%O%n%A%n%C %S %Z'], + ['AT', '%O%n%N%n%A%n%Z %C'], + ['AU', '%O%n%N%n%A%n%C %S %Z'], + ['AX', '%O%n%N%n%A%nAX-%Z %C%nÅLAND'], + ['AZ', '%N%n%O%n%A%nAZ %Z %C'], + ['BA', '%N%n%O%n%A%n%Z %C'], + ['BB', '%N%n%O%n%A%n%C, %S %Z'], + ['BD', '%N%n%O%n%A%n%C - %Z'], + ['BE', '%O%n%N%n%A%n%Z %C'], + ['BF', '%N%n%O%n%A%n%C %X'], + ['BG', '%N%n%O%n%A%n%Z %C'], + ['BH', '%N%n%O%n%A%n%C %Z'], + ['BL', '%O%n%N%n%A%n%Z %C %X'], + ['BM', '%N%n%O%n%A%n%C %Z'], + ['BN', '%N%n%O%n%A%n%C %Z'], + ['BR', '%O%n%N%n%A%n%D%n%C-%S%n%Z'], + ['BS', '%N%n%O%n%A%n%C, %S'], + ['BT', '%N%n%O%n%A%n%C %Z'], + ['BY', '%O%n%N%n%A%n%Z, %C%n%S'], + ['CA', '%N%n%O%n%A%n%C %S %Z'], + ['CC', '%O%n%N%n%A%n%C %S %Z'], + ['CH', '%O%n%N%n%A%nCH-%Z %C'], + ['CI', '%N%n%O%n%X %A %C %X'], + ['CL', '%N%n%O%n%A%n%Z %C%n%S'], + ['CN', '%Z%n%S%C%D%n%A%n%O%n%N'], + ['CO', '%N%n%O%n%A%n%C, %S, %Z'], + ['CR', '%N%n%O%n%A%n%S, %C%n%Z'], + ['CU', '%N%n%O%n%A%n%C %S%n%Z'], + ['CV', '%N%n%O%n%A%n%Z %C%n%S'], + ['CX', '%O%n%N%n%A%n%C %S %Z'], + ['CY', '%N%n%O%n%A%n%Z %C'], + ['CZ', '%N%n%O%n%A%n%Z %C'], + ['DE', '%N%n%O%n%A%n%Z %C'], + ['DK', '%N%n%O%n%A%n%Z %C'], + ['DO', '%N%n%O%n%A%n%Z %C'], + ['DZ', '%N%n%O%n%A%n%Z %C'], + ['EC', '%N%n%O%n%A%n%Z%n%C'], + ['EE', '%N%n%O%n%A%n%Z %C'], + ['EG', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['EH', '%N%n%O%n%A%n%Z %C'], + ['ES', '%N%n%O%n%A%n%Z %C %S'], + ['ET', '%N%n%O%n%A%n%Z %C'], + ['FI', '%O%n%N%n%A%nFI-%Z %C'], + ['FK', '%N%n%O%n%A%n%C%n%Z'], + ['FM', '%N%n%O%n%A%n%C %S %Z'], + ['FO', '%N%n%O%n%A%nFO%Z %C'], + ['FR', '%O%n%N%n%A%n%Z %C'], + ['GB', '%N%n%O%n%A%n%C%n%Z'], + ['GE', '%N%n%O%n%A%n%Z %C'], + ['GF', '%O%n%N%n%A%n%Z %C %X'], + ['GG', '%N%n%O%n%A%n%C%nGUERNSEY%n%Z'], + ['GI', '%N%n%O%n%A%nGIBRALTAR%n%Z'], + ['GL', '%N%n%O%n%A%n%Z %C'], + ['GN', '%N%n%O%n%Z %A %C'], + ['GP', '%O%n%N%n%A%n%Z %C %X'], + ['GR', '%N%n%O%n%A%n%Z %C'], + ['GS', '%N%n%O%n%A%n%n%C%n%Z'], + ['GT', '%N%n%O%n%A%n%Z- %C'], + ['GU', '%N%n%O%n%A%n%C %Z'], + ['GW', '%N%n%O%n%A%n%Z %C'], + ['HK', '%S%n%C%n%A%n%O%n%N'], + ['HM', '%O%n%N%n%A%n%C %S %Z'], + ['HN', '%N%n%O%n%A%n%C, %S%n%Z'], + ['HR', '%N%n%O%n%A%nHR-%Z %C'], + ['HT', '%N%n%O%n%A%nHT%Z %C'], + ['HU', '%N%n%O%n%C%n%A%n%Z'], + ['ID', '%N%n%O%n%A%n%C%n%S %Z'], + ['IE', '%N%n%O%n%A%n%D%n%C%n%S%n%Z'], + ['IL', '%N%n%O%n%A%n%C %Z'], + ['IM', '%N%n%O%n%A%n%C%n%Z'], + ['IN', '%N%n%O%n%A%n%C %Z%n%S'], + ['IO', '%N%n%O%n%A%n%C%n%Z'], + ['IQ', '%O%n%N%n%A%n%C, %S%n%Z'], + ['IR', '%O%n%N%n%S%n%C, %D%n%A%n%Z'], + ['IS', '%N%n%O%n%A%n%Z %C'], + ['IT', '%N%n%O%n%A%n%Z %C %S'], + ['JE', '%N%n%O%n%A%n%C%nJERSEY%n%Z'], + ['JM', '%N%n%O%n%A%n%C%n%S %X'], + ['JO', '%N%n%O%n%A%n%C %Z'], + ['JP', '〒%Z%n%S%n%A%n%O%n%N'], + ['KE', '%N%n%O%n%A%n%C%n%Z'], + ['KG', '%N%n%O%n%A%n%Z %C'], + ['KH', '%N%n%O%n%A%n%C %Z'], + ['KI', '%N%n%O%n%A%n%S%n%C'], + ['KN', '%N%n%O%n%A%n%C, %S'], + ['KP', '%Z%n%S%n%C%n%A%n%O%n%N'], + ['KR', '%S %C%D%n%A%n%O%n%N%n%Z'], + ['KW', '%N%n%O%n%A%n%Z %C'], + ['KY', '%N%n%O%n%A%n%S %Z'], + ['KZ', '%Z%n%S%n%C%n%A%n%O%n%N'], + ['LA', '%N%n%O%n%A%n%Z %C'], + ['LB', '%N%n%O%n%A%n%C %Z'], + ['LI', '%O%n%N%n%A%nFL-%Z %C'], + ['LK', '%N%n%O%n%A%n%C%n%Z'], + ['LR', '%N%n%O%n%A%n%Z %C'], + ['LS', '%N%n%O%n%A%n%C %Z'], + ['LT', '%O%n%N%n%A%nLT-%Z %C'], + ['LU', '%O%n%N%n%A%nL-%Z %C'], + ['LV', '%N%n%O%n%A%n%C, %Z'], + ['MA', '%N%n%O%n%A%n%Z %C'], + ['MC', '%N%n%O%n%A%nMC-%Z %C %X'], + ['MD', '%N%n%O%n%A%nMD-%Z %C'], + ['ME', '%N%n%O%n%A%n%Z %C'], + ['MF', '%O%n%N%n%A%n%Z %C %X'], + ['MG', '%N%n%O%n%A%n%Z %C'], + ['MH', '%N%n%O%n%A%n%C %S %Z'], + ['MK', '%N%n%O%n%A%n%Z %C'], + ['MM', '%N%n%O%n%A%n%C, %Z'], + ['MN', '%N%n%O%n%A%n%C%n%S %Z'], + ['MO', '%A%n%O%n%N'], + ['MP', '%N%n%O%n%A%n%C %S %Z'], + ['MQ', '%O%n%N%n%A%n%Z %C %X'], + ['MT', '%N%n%O%n%A%n%C %Z'], + ['MU', '%N%n%O%n%A%n%Z%n%C'], + ['MV', '%N%n%O%n%A%n%C %Z'], + ['MW', '%N%n%O%n%A%n%C %X'], + ['MX', '%N%n%O%n%A%n%D%n%Z %C, %S'], + ['MY', '%N%n%O%n%A%n%D%n%Z %C%n%S'], + ['MZ', '%N%n%O%n%A%n%Z %C%S'], + ['NA', '%N%n%O%n%A%n%C%n%Z'], + ['NC', '%O%n%N%n%A%n%Z %C %X'], + ['NE', '%N%n%O%n%A%n%Z %C'], + ['NF', '%O%n%N%n%A%n%C %S %Z'], + ['NG', '%N%n%O%n%A%n%D%n%C %Z%n%S'], + ['NI', '%N%n%O%n%A%n%Z%n%C, %S'], + ['NL', '%O%n%N%n%A%n%Z %C'], + ['NO', '%N%n%O%n%A%n%Z %C'], + ['NP', '%N%n%O%n%A%n%C %Z'], + ['NR', '%N%n%O%n%A%n%S'], + ['NZ', '%N%n%O%n%A%n%D%n%C %Z'], + ['OM', '%N%n%O%n%A%n%Z%n%C'], + ['PA', '%N%n%O%n%A%n%C%n%S'], + ['PE', '%N%n%O%n%A%n%C %Z%n%S'], + ['PF', '%N%n%O%n%A%n%Z %C %S'], + ['PG', '%N%n%O%n%A%n%C %Z %S'], + ['PH', '%N%n%O%n%A%n%D, %C%n%Z %S'], + ['PK', '%N%n%O%n%A%n%C-%Z'], + ['PL', '%N%n%O%n%A%n%Z %C'], + ['PM', '%O%n%N%n%A%n%Z %C %X'], + ['PN', '%N%n%O%n%A%n%C%n%Z'], + ['PR', '%N%n%O%n%A%n%C PR %Z'], + ['PT', '%N%n%O%n%A%n%Z %C'], + ['PW', '%N%n%O%n%A%n%C %S %Z'], + ['PY', '%N%n%O%n%A%n%Z %C'], + ['RE', '%O%n%N%n%A%n%Z %C %X'], + ['RO', '%N%n%O%n%A%n%Z %C'], + ['RS', '%N%n%O%n%A%n%Z %C'], + ['RU', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['SA', '%N%n%O%n%A%n%C %Z'], + ['SC', '%N%n%O%n%A%n%C%n%S'], + ['SD', '%N%n%O%n%A%n%C%n%Z'], + ['SE', '%O%n%N%n%A%nSE-%Z %C'], + ['SG', '%N%n%O%n%A%nSINGAPORE %Z'], + ['SH', '%N%n%O%n%A%n%C%n%Z'], + ['SI', '%N%n%O%n%A%nSI-%Z %C'], + ['SJ', '%N%n%O%n%A%n%Z %C'], + ['SK', '%N%n%O%n%A%n%Z %C'], + ['SM', '%N%n%O%n%A%n%Z %C'], + ['SN', '%N%n%O%n%A%n%Z %C'], + ['SO', '%N%n%O%n%A%n%C, %S %Z'], + ['SR', '%N%n%O%n%A%n%C%n%S'], + ['SV', '%N%n%O%n%A%n%Z-%C%n%S'], + ['SZ', '%N%n%O%n%A%n%C%n%Z'], + ['TA', '%N%n%O%n%A%n%C%n%Z'], + ['TC', '%N%n%O%n%A%n%C%n%Z'], + ['TH', '%N%n%O%n%A%n%D %C%n%S %Z'], + ['TJ', '%N%n%O%n%A%n%Z %C'], + ['TM', '%N%n%O%n%A%n%Z %C'], + ['TN', '%N%n%O%n%A%n%Z %C'], + ['TR', '%N%n%O%n%A%n%Z %C/%S'], + ['TV', '%N%n%O%n%A%n%C%n%S'], + ['TW', '%Z%n%S%C%n%A%n%O%n%N'], + ['TZ', '%N%n%O%n%A%n%Z %C'], + ['UA', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['UM', '%N%n%O%n%A%n%C %S %Z'], + ['US', '%N%n%O%n%A%n%C, %S %Z'], + ['UY', '%N%n%O%n%A%n%Z %C %S'], + ['UZ', '%N%n%O%n%A%n%Z %C%n%S'], + ['VA', '%N%n%O%n%A%n%Z %C'], + ['VC', '%N%n%O%n%A%n%C %Z'], + ['VE', '%N%n%O%n%A%n%C %Z, %S'], + ['VG', '%N%n%O%n%A%n%C%n%Z'], + ['VI', '%N%n%O%n%A%n%C %S %Z'], + ['VN', '%N%n%O%n%A%n%C%n%S %Z'], + ['WF', '%O%n%N%n%A%n%Z %C %X'], + ['XK', '%N%n%O%n%A%n%Z %C'], + ['YT', '%O%n%N%n%A%n%Z %C %X'], + ['ZA', '%N%n%O%n%A%n%D%n%C%n%Z'], + ['ZM', '%N%n%O%n%A%n%Z %C'], +]); +const defaultAddressFormat = '%N%n%O%n%A%n%C'; + +const getFormatString = (countryCode) => { + var _a; + return (_a = addressFormats.get(countryCode.toUpperCase())) !== null && _a !== void 0 ? _a : defaultAddressFormat; +}; +const getFormatSubstrings = (format) => { + const parts = []; + let escaped = false; + let currentLiteral = ''; + for (const char of format) { + if (escaped) { + escaped = false; + parts.push(`%${char}`); + continue; + } + if (char !== '%') { + currentLiteral += char; + continue; + } + if (currentLiteral.length > 0) { + parts.push(currentLiteral); + currentLiteral = ''; + } + escaped = true; + } + if (currentLiteral.length > 0) { + parts.push(currentLiteral); + } + return parts; +}; +const fields = new Map([ + ['%N', 'name'], + ['%O', 'organization'], + ['%A', 'addressLines'], + ['%D', 'dependentLocality'], + ['%C', 'locality'], + ['%S', 'administrativeArea'], + ['%Z', 'postalCode'], + ['%X', 'sortingCode'], + ['%R', 'postalCountry'], +]); +const getFieldForFormatSubstring = (formatSubstring) => { + const field = fields.get(formatSubstring); + /* istanbul ignore next imported format strings should never contain invalid substrings */ + if (!field) { + throw new Error(`Could not find field for format substring ${formatSubstring}`); + } + return field; +}; +const addressHasValueForField = (address, field) => { + if (field === 'addressLines') { + return address.addressLines !== undefined && address.addressLines.length > 0; + } + return address[field] !== undefined && address[field] !== ''; +}; +const formatSubstringRepresentsField = (formatSubstring) => { + return formatSubstring !== '%n' && formatSubstring.startsWith('%'); +}; +const pruneFormat = (formatSubstrings, address) => { + const prunedFormat = []; + for (const [i, formatSubstring] of formatSubstrings.entries()) { + // Always keep the newlines. + if (formatSubstring === '%n') { + prunedFormat.push(formatSubstring); + continue; + } + if (formatSubstringRepresentsField(formatSubstring)) { + // Always keep non-empty address fields. + if (addressHasValueForField(address, getFieldForFormatSubstring(formatSubstring))) { + prunedFormat.push(formatSubstring); + } + continue; + } + // Only keep literals that satisfy these two conditions: + // 1. Not preceding an empty field. + // 2. Not following a removed field. + if ((i === formatSubstrings.length - 1 + || formatSubstrings[i + 1] === '%n' + || addressHasValueForField(address, getFieldForFormatSubstring(formatSubstrings[i + 1]))) && (i === 0 + || !formatSubstringRepresentsField(formatSubstrings[i - 1]) + || (prunedFormat.length > 0 && formatSubstringRepresentsField(prunedFormat[prunedFormat.length - 1])))) { + prunedFormat.push(formatSubstring); + } + } + return prunedFormat; +}; +const formatAddress = (address) => { + var _a; + const formatString = getFormatString((_a = address.postalCountry) !== null && _a !== void 0 ? _a : 'ZZ'); + const formatSubstrings = getFormatSubstrings(formatString); + const prunedFormat = pruneFormat(formatSubstrings, address); + const lines = []; + let currentLine = ''; + for (const formatSubstring of prunedFormat) { + if (formatSubstring === '%n') { + if (currentLine.length > 0) { + lines.push(currentLine); + currentLine = ''; + } + continue; + } + if (!formatSubstringRepresentsField(formatSubstring)) { + // Not a symbol we recognize, so must be a literal. We append it unchanged. + currentLine += formatSubstring; + continue; + } + const field = getFieldForFormatSubstring(formatSubstring); + /* istanbul ignore next imported format strings should never contain the postal country */ + if (field === 'postalCountry') { + // Country name is treated separately. + continue; + } + if (field === 'addressLines') { + // The field "address lines" represents the address lines of an address, so there can be multiple values. + // It is safe to assert addressLines to be defined here, as the pruning process already checked for that. + const addressLines = address.addressLines.filter(addressLine => addressLine !== ''); + if (addressLines.length === 0) { + // Empty address lines are ignored. + continue; + } + currentLine += addressLines[0]; + if (addressLines.length > 1) { + lines.push(currentLine); + currentLine = ''; + lines.push(...addressLines.slice(1)); + } + continue; + } + // Any other field can be appended as is. + currentLine += address[field]; + } + if (currentLine.length > 0) { + lines.push(currentLine); + } + return lines; +}; + +exports.formatAddress = formatAddress; +//# sourceMappingURL=index.cjs.js.map diff --git a/dist/index.cjs.js.map b/dist/index.cjs.js.map new file mode 100644 index 0000000..8103f32 --- /dev/null +++ b/dist/index.cjs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.cjs.js","sources":["../src/addressFormats.ts","../src/formatAddress.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;AAAA;AAEA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAiB;IAC3C,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAC5B,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAC3B,CAAC,IAAI,EAAE,gBAAgB,CAAC;IACxB,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAC5B,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAC5B,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAC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C,aAAA;YAED,SAAS;AACZ,SAAA;;AAGD,QAAA,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AACjC,KAAA;AAED,IAAA,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;AACxB,QAAA,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC3B,KAAA;AAED,IAAA,OAAO,KAAK,CAAC;AACjB;;;;"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..742dcd3 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,2 @@ +export type { Address } from './formatAddress'; +export { default as formatAddress } from './formatAddress'; diff --git a/dist/index.esm.js b/dist/index.esm.js new file mode 100644 index 0000000..f5fd15e --- /dev/null +++ b/dist/index.esm.js @@ -0,0 +1,340 @@ +// This file is auto-generated via "npm run update-formats". Do not alter manually! +const addressFormats = new Map([ + ['AC', '%N%n%O%n%A%n%C%n%Z'], + ['AD', '%N%n%O%n%A%n%Z %C'], + ['AE', '%N%n%O%n%A%n%S'], + ['AF', '%N%n%O%n%A%n%C%n%Z'], + ['AI', '%N%n%O%n%A%n%C%n%Z'], + ['AL', '%N%n%O%n%A%n%Z%n%C'], + ['AM', '%N%n%O%n%A%n%Z%n%C%n%S'], + ['AR', '%N%n%O%n%A%n%Z %C%n%S'], + ['AS', '%N%n%O%n%A%n%C %S %Z'], + ['AT', '%O%n%N%n%A%n%Z %C'], + ['AU', '%O%n%N%n%A%n%C %S %Z'], + ['AX', '%O%n%N%n%A%nAX-%Z %C%nÅLAND'], + ['AZ', '%N%n%O%n%A%nAZ %Z %C'], + ['BA', '%N%n%O%n%A%n%Z %C'], + ['BB', '%N%n%O%n%A%n%C, %S %Z'], + ['BD', '%N%n%O%n%A%n%C - %Z'], + ['BE', '%O%n%N%n%A%n%Z %C'], + ['BF', '%N%n%O%n%A%n%C %X'], + ['BG', '%N%n%O%n%A%n%Z %C'], + ['BH', '%N%n%O%n%A%n%C %Z'], + ['BL', '%O%n%N%n%A%n%Z %C %X'], + ['BM', '%N%n%O%n%A%n%C %Z'], + ['BN', '%N%n%O%n%A%n%C %Z'], + ['BR', '%O%n%N%n%A%n%D%n%C-%S%n%Z'], + ['BS', '%N%n%O%n%A%n%C, %S'], + ['BT', '%N%n%O%n%A%n%C %Z'], + ['BY', '%O%n%N%n%A%n%Z, %C%n%S'], + ['CA', '%N%n%O%n%A%n%C %S %Z'], + ['CC', '%O%n%N%n%A%n%C %S %Z'], + ['CH', '%O%n%N%n%A%nCH-%Z %C'], + ['CI', '%N%n%O%n%X %A %C %X'], + ['CL', '%N%n%O%n%A%n%Z %C%n%S'], + ['CN', '%Z%n%S%C%D%n%A%n%O%n%N'], + ['CO', '%N%n%O%n%A%n%C, %S, %Z'], + ['CR', '%N%n%O%n%A%n%S, %C%n%Z'], + ['CU', '%N%n%O%n%A%n%C %S%n%Z'], + ['CV', '%N%n%O%n%A%n%Z %C%n%S'], + ['CX', '%O%n%N%n%A%n%C %S %Z'], + ['CY', '%N%n%O%n%A%n%Z %C'], + ['CZ', '%N%n%O%n%A%n%Z %C'], + ['DE', '%N%n%O%n%A%n%Z %C'], + ['DK', '%N%n%O%n%A%n%Z %C'], + ['DO', '%N%n%O%n%A%n%Z %C'], + ['DZ', '%N%n%O%n%A%n%Z %C'], + ['EC', '%N%n%O%n%A%n%Z%n%C'], + ['EE', '%N%n%O%n%A%n%Z %C'], + ['EG', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['EH', '%N%n%O%n%A%n%Z %C'], + ['ES', '%N%n%O%n%A%n%Z %C %S'], + ['ET', '%N%n%O%n%A%n%Z %C'], + ['FI', '%O%n%N%n%A%nFI-%Z %C'], + ['FK', '%N%n%O%n%A%n%C%n%Z'], + ['FM', '%N%n%O%n%A%n%C %S %Z'], + ['FO', '%N%n%O%n%A%nFO%Z %C'], + ['FR', '%O%n%N%n%A%n%Z %C'], + ['GB', '%N%n%O%n%A%n%C%n%Z'], + ['GE', '%N%n%O%n%A%n%Z %C'], + ['GF', '%O%n%N%n%A%n%Z %C %X'], + ['GG', '%N%n%O%n%A%n%C%nGUERNSEY%n%Z'], + ['GI', '%N%n%O%n%A%nGIBRALTAR%n%Z'], + ['GL', '%N%n%O%n%A%n%Z %C'], + ['GN', '%N%n%O%n%Z %A %C'], + ['GP', '%O%n%N%n%A%n%Z %C %X'], + ['GR', '%N%n%O%n%A%n%Z %C'], + ['GS', '%N%n%O%n%A%n%n%C%n%Z'], + ['GT', '%N%n%O%n%A%n%Z- %C'], + ['GU', '%N%n%O%n%A%n%C %Z'], + ['GW', '%N%n%O%n%A%n%Z %C'], + ['HK', '%S%n%C%n%A%n%O%n%N'], + ['HM', '%O%n%N%n%A%n%C %S %Z'], + ['HN', '%N%n%O%n%A%n%C, %S%n%Z'], + ['HR', '%N%n%O%n%A%nHR-%Z %C'], + ['HT', '%N%n%O%n%A%nHT%Z %C'], + ['HU', '%N%n%O%n%C%n%A%n%Z'], + ['ID', '%N%n%O%n%A%n%C%n%S %Z'], + ['IE', '%N%n%O%n%A%n%D%n%C%n%S%n%Z'], + ['IL', '%N%n%O%n%A%n%C %Z'], + ['IM', '%N%n%O%n%A%n%C%n%Z'], + ['IN', '%N%n%O%n%A%n%C %Z%n%S'], + ['IO', '%N%n%O%n%A%n%C%n%Z'], + ['IQ', '%O%n%N%n%A%n%C, %S%n%Z'], + ['IR', '%O%n%N%n%S%n%C, %D%n%A%n%Z'], + ['IS', '%N%n%O%n%A%n%Z %C'], + ['IT', '%N%n%O%n%A%n%Z %C %S'], + ['JE', '%N%n%O%n%A%n%C%nJERSEY%n%Z'], + ['JM', '%N%n%O%n%A%n%C%n%S %X'], + ['JO', '%N%n%O%n%A%n%C %Z'], + ['JP', '〒%Z%n%S%n%A%n%O%n%N'], + ['KE', '%N%n%O%n%A%n%C%n%Z'], + ['KG', '%N%n%O%n%A%n%Z %C'], + ['KH', '%N%n%O%n%A%n%C %Z'], + ['KI', '%N%n%O%n%A%n%S%n%C'], + ['KN', '%N%n%O%n%A%n%C, %S'], + ['KP', '%Z%n%S%n%C%n%A%n%O%n%N'], + ['KR', '%S %C%D%n%A%n%O%n%N%n%Z'], + ['KW', '%N%n%O%n%A%n%Z %C'], + ['KY', '%N%n%O%n%A%n%S %Z'], + ['KZ', '%Z%n%S%n%C%n%A%n%O%n%N'], + ['LA', '%N%n%O%n%A%n%Z %C'], + ['LB', '%N%n%O%n%A%n%C %Z'], + ['LI', '%O%n%N%n%A%nFL-%Z %C'], + ['LK', '%N%n%O%n%A%n%C%n%Z'], + ['LR', '%N%n%O%n%A%n%Z %C'], + ['LS', '%N%n%O%n%A%n%C %Z'], + ['LT', '%O%n%N%n%A%nLT-%Z %C'], + ['LU', '%O%n%N%n%A%nL-%Z %C'], + ['LV', '%N%n%O%n%A%n%C, %Z'], + ['MA', '%N%n%O%n%A%n%Z %C'], + ['MC', '%N%n%O%n%A%nMC-%Z %C %X'], + ['MD', '%N%n%O%n%A%nMD-%Z %C'], + ['ME', '%N%n%O%n%A%n%Z %C'], + ['MF', '%O%n%N%n%A%n%Z %C %X'], + ['MG', '%N%n%O%n%A%n%Z %C'], + ['MH', '%N%n%O%n%A%n%C %S %Z'], + ['MK', '%N%n%O%n%A%n%Z %C'], + ['MM', '%N%n%O%n%A%n%C, %Z'], + ['MN', '%N%n%O%n%A%n%C%n%S %Z'], + ['MO', '%A%n%O%n%N'], + ['MP', '%N%n%O%n%A%n%C %S %Z'], + ['MQ', '%O%n%N%n%A%n%Z %C %X'], + ['MT', '%N%n%O%n%A%n%C %Z'], + ['MU', '%N%n%O%n%A%n%Z%n%C'], + ['MV', '%N%n%O%n%A%n%C %Z'], + ['MW', '%N%n%O%n%A%n%C %X'], + ['MX', '%N%n%O%n%A%n%D%n%Z %C, %S'], + ['MY', '%N%n%O%n%A%n%D%n%Z %C%n%S'], + ['MZ', '%N%n%O%n%A%n%Z %C%S'], + ['NA', '%N%n%O%n%A%n%C%n%Z'], + ['NC', '%O%n%N%n%A%n%Z %C %X'], + ['NE', '%N%n%O%n%A%n%Z %C'], + ['NF', '%O%n%N%n%A%n%C %S %Z'], + ['NG', '%N%n%O%n%A%n%D%n%C %Z%n%S'], + ['NI', '%N%n%O%n%A%n%Z%n%C, %S'], + ['NL', '%O%n%N%n%A%n%Z %C'], + ['NO', '%N%n%O%n%A%n%Z %C'], + ['NP', '%N%n%O%n%A%n%C %Z'], + ['NR', '%N%n%O%n%A%n%S'], + ['NZ', '%N%n%O%n%A%n%D%n%C %Z'], + ['OM', '%N%n%O%n%A%n%Z%n%C'], + ['PA', '%N%n%O%n%A%n%C%n%S'], + ['PE', '%N%n%O%n%A%n%C %Z%n%S'], + ['PF', '%N%n%O%n%A%n%Z %C %S'], + ['PG', '%N%n%O%n%A%n%C %Z %S'], + ['PH', '%N%n%O%n%A%n%D, %C%n%Z %S'], + ['PK', '%N%n%O%n%A%n%C-%Z'], + ['PL', '%N%n%O%n%A%n%Z %C'], + ['PM', '%O%n%N%n%A%n%Z %C %X'], + ['PN', '%N%n%O%n%A%n%C%n%Z'], + ['PR', '%N%n%O%n%A%n%C PR %Z'], + ['PT', '%N%n%O%n%A%n%Z %C'], + ['PW', '%N%n%O%n%A%n%C %S %Z'], + ['PY', '%N%n%O%n%A%n%Z %C'], + ['RE', '%O%n%N%n%A%n%Z %C %X'], + ['RO', '%N%n%O%n%A%n%Z %C'], + ['RS', '%N%n%O%n%A%n%Z %C'], + ['RU', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['SA', '%N%n%O%n%A%n%C %Z'], + ['SC', '%N%n%O%n%A%n%C%n%S'], + ['SD', '%N%n%O%n%A%n%C%n%Z'], + ['SE', '%O%n%N%n%A%nSE-%Z %C'], + ['SG', '%N%n%O%n%A%nSINGAPORE %Z'], + ['SH', '%N%n%O%n%A%n%C%n%Z'], + ['SI', '%N%n%O%n%A%nSI-%Z %C'], + ['SJ', '%N%n%O%n%A%n%Z %C'], + ['SK', '%N%n%O%n%A%n%Z %C'], + ['SM', '%N%n%O%n%A%n%Z %C'], + ['SN', '%N%n%O%n%A%n%Z %C'], + ['SO', '%N%n%O%n%A%n%C, %S %Z'], + ['SR', '%N%n%O%n%A%n%C%n%S'], + ['SV', '%N%n%O%n%A%n%Z-%C%n%S'], + ['SZ', '%N%n%O%n%A%n%C%n%Z'], + ['TA', '%N%n%O%n%A%n%C%n%Z'], + ['TC', '%N%n%O%n%A%n%C%n%Z'], + ['TH', '%N%n%O%n%A%n%D %C%n%S %Z'], + ['TJ', '%N%n%O%n%A%n%Z %C'], + ['TM', '%N%n%O%n%A%n%Z %C'], + ['TN', '%N%n%O%n%A%n%Z %C'], + ['TR', '%N%n%O%n%A%n%Z %C/%S'], + ['TV', '%N%n%O%n%A%n%C%n%S'], + ['TW', '%Z%n%S%C%n%A%n%O%n%N'], + ['TZ', '%N%n%O%n%A%n%Z %C'], + ['UA', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['UM', '%N%n%O%n%A%n%C %S %Z'], + ['US', '%N%n%O%n%A%n%C, %S %Z'], + ['UY', '%N%n%O%n%A%n%Z %C %S'], + ['UZ', '%N%n%O%n%A%n%Z %C%n%S'], + ['VA', '%N%n%O%n%A%n%Z %C'], + ['VC', '%N%n%O%n%A%n%C %Z'], + ['VE', '%N%n%O%n%A%n%C %Z, %S'], + ['VG', '%N%n%O%n%A%n%C%n%Z'], + ['VI', '%N%n%O%n%A%n%C %S %Z'], + ['VN', '%N%n%O%n%A%n%C%n%S %Z'], + ['WF', '%O%n%N%n%A%n%Z %C %X'], + ['XK', '%N%n%O%n%A%n%Z %C'], + ['YT', '%O%n%N%n%A%n%Z %C %X'], + ['ZA', '%N%n%O%n%A%n%D%n%C%n%Z'], + ['ZM', '%N%n%O%n%A%n%Z %C'], +]); +const defaultAddressFormat = '%N%n%O%n%A%n%C'; + +const getFormatString = (countryCode) => { + var _a; + return (_a = addressFormats.get(countryCode.toUpperCase())) !== null && _a !== void 0 ? _a : defaultAddressFormat; +}; +const getFormatSubstrings = (format) => { + const parts = []; + let escaped = false; + let currentLiteral = ''; + for (const char of format) { + if (escaped) { + escaped = false; + parts.push(`%${char}`); + continue; + } + if (char !== '%') { + currentLiteral += char; + continue; + } + if (currentLiteral.length > 0) { + parts.push(currentLiteral); + currentLiteral = ''; + } + escaped = true; + } + if (currentLiteral.length > 0) { + parts.push(currentLiteral); + } + return parts; +}; +const fields = new Map([ + ['%N', 'name'], + ['%O', 'organization'], + ['%A', 'addressLines'], + ['%D', 'dependentLocality'], + ['%C', 'locality'], + ['%S', 'administrativeArea'], + ['%Z', 'postalCode'], + ['%X', 'sortingCode'], + ['%R', 'postalCountry'], +]); +const getFieldForFormatSubstring = (formatSubstring) => { + const field = fields.get(formatSubstring); + /* istanbul ignore next imported format strings should never contain invalid substrings */ + if (!field) { + throw new Error(`Could not find field for format substring ${formatSubstring}`); + } + return field; +}; +const addressHasValueForField = (address, field) => { + if (field === 'addressLines') { + return address.addressLines !== undefined && address.addressLines.length > 0; + } + return address[field] !== undefined && address[field] !== ''; +}; +const formatSubstringRepresentsField = (formatSubstring) => { + return formatSubstring !== '%n' && formatSubstring.startsWith('%'); +}; +const pruneFormat = (formatSubstrings, address) => { + const prunedFormat = []; + for (const [i, formatSubstring] of formatSubstrings.entries()) { + // Always keep the newlines. + if (formatSubstring === '%n') { + prunedFormat.push(formatSubstring); + continue; + } + if (formatSubstringRepresentsField(formatSubstring)) { + // Always keep non-empty address fields. + if (addressHasValueForField(address, getFieldForFormatSubstring(formatSubstring))) { + prunedFormat.push(formatSubstring); + } + continue; + } + // Only keep literals that satisfy these two conditions: + // 1. Not preceding an empty field. + // 2. Not following a removed field. + if ((i === formatSubstrings.length - 1 + || formatSubstrings[i + 1] === '%n' + || addressHasValueForField(address, getFieldForFormatSubstring(formatSubstrings[i + 1]))) && (i === 0 + || !formatSubstringRepresentsField(formatSubstrings[i - 1]) + || (prunedFormat.length > 0 && formatSubstringRepresentsField(prunedFormat[prunedFormat.length - 1])))) { + prunedFormat.push(formatSubstring); + } + } + return prunedFormat; +}; +const formatAddress = (address) => { + var _a; + const formatString = getFormatString((_a = address.postalCountry) !== null && _a !== void 0 ? _a : 'ZZ'); + const formatSubstrings = getFormatSubstrings(formatString); + const prunedFormat = pruneFormat(formatSubstrings, address); + const lines = []; + let currentLine = ''; + for (const formatSubstring of prunedFormat) { + if (formatSubstring === '%n') { + if (currentLine.length > 0) { + lines.push(currentLine); + currentLine = ''; + } + continue; + } + if (!formatSubstringRepresentsField(formatSubstring)) { + // Not a symbol we recognize, so must be a literal. We append it unchanged. + currentLine += formatSubstring; + continue; + } + const field = getFieldForFormatSubstring(formatSubstring); + /* istanbul ignore next imported format strings should never contain the postal country */ + if (field === 'postalCountry') { + // Country name is treated separately. + continue; + } + if (field === 'addressLines') { + // The field "address lines" represents the address lines of an address, so there can be multiple values. + // It is safe to assert addressLines to be defined here, as the pruning process already checked for that. + const addressLines = address.addressLines.filter(addressLine => addressLine !== ''); + if (addressLines.length === 0) { + // Empty address lines are ignored. + continue; + } + currentLine += addressLines[0]; + if (addressLines.length > 1) { + lines.push(currentLine); + currentLine = ''; + lines.push(...addressLines.slice(1)); + } + continue; + } + // Any other field can be appended as is. + currentLine += address[field]; + } + if (currentLine.length > 0) { + lines.push(currentLine); + } + return lines; +}; + +export { formatAddress }; +//# sourceMappingURL=index.esm.js.map diff --git a/dist/index.esm.js.map b/dist/index.esm.js.map new file mode 100644 index 0000000..bc7e1b2 --- /dev/null +++ b/dist/index.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.esm.js","sources":["../src/addressFormats.ts","../src/formatAddress.ts"],"sourcesContent":[null,null],"names":[],"mappings":"AAAA;AAEA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAiB;IAC3C,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAC5B,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAC3B,CAAC,IAAI,EAAE,gBAAgB,CAAC;IACxB,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAC5B,CAAC,IAAI,EAAE,o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AAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,aAAA;YAED,SAAS;AACZ,SAAA;;AAGD,QAAA,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AACjC,KAAA;AAED,IAAA,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;AACxB,QAAA,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC3B,KAAA;AAED,IAAA,OAAO,KAAK,CAAC;AACjB;;;;"} \ No newline at end of file diff --git a/dist/index.umd.js b/dist/index.umd.js new file mode 100644 index 0000000..a7e22b6 --- /dev/null +++ b/dist/index.umd.js @@ -0,0 +1,350 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.localizedAddressFormat = {})); +})(this, (function (exports) { 'use strict'; + + // This file is auto-generated via "npm run update-formats". Do not alter manually! + const addressFormats = new Map([ + ['AC', '%N%n%O%n%A%n%C%n%Z'], + ['AD', '%N%n%O%n%A%n%Z %C'], + ['AE', '%N%n%O%n%A%n%S'], + ['AF', '%N%n%O%n%A%n%C%n%Z'], + ['AI', '%N%n%O%n%A%n%C%n%Z'], + ['AL', '%N%n%O%n%A%n%Z%n%C'], + ['AM', '%N%n%O%n%A%n%Z%n%C%n%S'], + ['AR', '%N%n%O%n%A%n%Z %C%n%S'], + ['AS', '%N%n%O%n%A%n%C %S %Z'], + ['AT', '%O%n%N%n%A%n%Z %C'], + ['AU', '%O%n%N%n%A%n%C %S %Z'], + ['AX', '%O%n%N%n%A%nAX-%Z %C%nÅLAND'], + ['AZ', '%N%n%O%n%A%nAZ %Z %C'], + ['BA', '%N%n%O%n%A%n%Z %C'], + ['BB', '%N%n%O%n%A%n%C, %S %Z'], + ['BD', '%N%n%O%n%A%n%C - %Z'], + ['BE', '%O%n%N%n%A%n%Z %C'], + ['BF', '%N%n%O%n%A%n%C %X'], + ['BG', '%N%n%O%n%A%n%Z %C'], + ['BH', '%N%n%O%n%A%n%C %Z'], + ['BL', '%O%n%N%n%A%n%Z %C %X'], + ['BM', '%N%n%O%n%A%n%C %Z'], + ['BN', '%N%n%O%n%A%n%C %Z'], + ['BR', '%O%n%N%n%A%n%D%n%C-%S%n%Z'], + ['BS', '%N%n%O%n%A%n%C, %S'], + ['BT', '%N%n%O%n%A%n%C %Z'], + ['BY', '%O%n%N%n%A%n%Z, %C%n%S'], + ['CA', '%N%n%O%n%A%n%C %S %Z'], + ['CC', '%O%n%N%n%A%n%C %S %Z'], + ['CH', '%O%n%N%n%A%nCH-%Z %C'], + ['CI', '%N%n%O%n%X %A %C %X'], + ['CL', '%N%n%O%n%A%n%Z %C%n%S'], + ['CN', '%Z%n%S%C%D%n%A%n%O%n%N'], + ['CO', '%N%n%O%n%A%n%C, %S, %Z'], + ['CR', '%N%n%O%n%A%n%S, %C%n%Z'], + ['CU', '%N%n%O%n%A%n%C %S%n%Z'], + ['CV', '%N%n%O%n%A%n%Z %C%n%S'], + ['CX', '%O%n%N%n%A%n%C %S %Z'], + ['CY', '%N%n%O%n%A%n%Z %C'], + ['CZ', '%N%n%O%n%A%n%Z %C'], + ['DE', '%N%n%O%n%A%n%Z %C'], + ['DK', '%N%n%O%n%A%n%Z %C'], + ['DO', '%N%n%O%n%A%n%Z %C'], + ['DZ', '%N%n%O%n%A%n%Z %C'], + ['EC', '%N%n%O%n%A%n%Z%n%C'], + ['EE', '%N%n%O%n%A%n%Z %C'], + ['EG', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['EH', '%N%n%O%n%A%n%Z %C'], + ['ES', '%N%n%O%n%A%n%Z %C %S'], + ['ET', '%N%n%O%n%A%n%Z %C'], + ['FI', '%O%n%N%n%A%nFI-%Z %C'], + ['FK', '%N%n%O%n%A%n%C%n%Z'], + ['FM', '%N%n%O%n%A%n%C %S %Z'], + ['FO', '%N%n%O%n%A%nFO%Z %C'], + ['FR', '%O%n%N%n%A%n%Z %C'], + ['GB', '%N%n%O%n%A%n%C%n%Z'], + ['GE', '%N%n%O%n%A%n%Z %C'], + ['GF', '%O%n%N%n%A%n%Z %C %X'], + ['GG', '%N%n%O%n%A%n%C%nGUERNSEY%n%Z'], + ['GI', '%N%n%O%n%A%nGIBRALTAR%n%Z'], + ['GL', '%N%n%O%n%A%n%Z %C'], + ['GN', '%N%n%O%n%Z %A %C'], + ['GP', '%O%n%N%n%A%n%Z %C %X'], + ['GR', '%N%n%O%n%A%n%Z %C'], + ['GS', '%N%n%O%n%A%n%n%C%n%Z'], + ['GT', '%N%n%O%n%A%n%Z- %C'], + ['GU', '%N%n%O%n%A%n%C %Z'], + ['GW', '%N%n%O%n%A%n%Z %C'], + ['HK', '%S%n%C%n%A%n%O%n%N'], + ['HM', '%O%n%N%n%A%n%C %S %Z'], + ['HN', '%N%n%O%n%A%n%C, %S%n%Z'], + ['HR', '%N%n%O%n%A%nHR-%Z %C'], + ['HT', '%N%n%O%n%A%nHT%Z %C'], + ['HU', '%N%n%O%n%C%n%A%n%Z'], + ['ID', '%N%n%O%n%A%n%C%n%S %Z'], + ['IE', '%N%n%O%n%A%n%D%n%C%n%S%n%Z'], + ['IL', '%N%n%O%n%A%n%C %Z'], + ['IM', '%N%n%O%n%A%n%C%n%Z'], + ['IN', '%N%n%O%n%A%n%C %Z%n%S'], + ['IO', '%N%n%O%n%A%n%C%n%Z'], + ['IQ', '%O%n%N%n%A%n%C, %S%n%Z'], + ['IR', '%O%n%N%n%S%n%C, %D%n%A%n%Z'], + ['IS', '%N%n%O%n%A%n%Z %C'], + ['IT', '%N%n%O%n%A%n%Z %C %S'], + ['JE', '%N%n%O%n%A%n%C%nJERSEY%n%Z'], + ['JM', '%N%n%O%n%A%n%C%n%S %X'], + ['JO', '%N%n%O%n%A%n%C %Z'], + ['JP', '〒%Z%n%S%n%A%n%O%n%N'], + ['KE', '%N%n%O%n%A%n%C%n%Z'], + ['KG', '%N%n%O%n%A%n%Z %C'], + ['KH', '%N%n%O%n%A%n%C %Z'], + ['KI', '%N%n%O%n%A%n%S%n%C'], + ['KN', '%N%n%O%n%A%n%C, %S'], + ['KP', '%Z%n%S%n%C%n%A%n%O%n%N'], + ['KR', '%S %C%D%n%A%n%O%n%N%n%Z'], + ['KW', '%N%n%O%n%A%n%Z %C'], + ['KY', '%N%n%O%n%A%n%S %Z'], + ['KZ', '%Z%n%S%n%C%n%A%n%O%n%N'], + ['LA', '%N%n%O%n%A%n%Z %C'], + ['LB', '%N%n%O%n%A%n%C %Z'], + ['LI', '%O%n%N%n%A%nFL-%Z %C'], + ['LK', '%N%n%O%n%A%n%C%n%Z'], + ['LR', '%N%n%O%n%A%n%Z %C'], + ['LS', '%N%n%O%n%A%n%C %Z'], + ['LT', '%O%n%N%n%A%nLT-%Z %C'], + ['LU', '%O%n%N%n%A%nL-%Z %C'], + ['LV', '%N%n%O%n%A%n%C, %Z'], + ['MA', '%N%n%O%n%A%n%Z %C'], + ['MC', '%N%n%O%n%A%nMC-%Z %C %X'], + ['MD', '%N%n%O%n%A%nMD-%Z %C'], + ['ME', '%N%n%O%n%A%n%Z %C'], + ['MF', '%O%n%N%n%A%n%Z %C %X'], + ['MG', '%N%n%O%n%A%n%Z %C'], + ['MH', '%N%n%O%n%A%n%C %S %Z'], + ['MK', '%N%n%O%n%A%n%Z %C'], + ['MM', '%N%n%O%n%A%n%C, %Z'], + ['MN', '%N%n%O%n%A%n%C%n%S %Z'], + ['MO', '%A%n%O%n%N'], + ['MP', '%N%n%O%n%A%n%C %S %Z'], + ['MQ', '%O%n%N%n%A%n%Z %C %X'], + ['MT', '%N%n%O%n%A%n%C %Z'], + ['MU', '%N%n%O%n%A%n%Z%n%C'], + ['MV', '%N%n%O%n%A%n%C %Z'], + ['MW', '%N%n%O%n%A%n%C %X'], + ['MX', '%N%n%O%n%A%n%D%n%Z %C, %S'], + ['MY', '%N%n%O%n%A%n%D%n%Z %C%n%S'], + ['MZ', '%N%n%O%n%A%n%Z %C%S'], + ['NA', '%N%n%O%n%A%n%C%n%Z'], + ['NC', '%O%n%N%n%A%n%Z %C %X'], + ['NE', '%N%n%O%n%A%n%Z %C'], + ['NF', '%O%n%N%n%A%n%C %S %Z'], + ['NG', '%N%n%O%n%A%n%D%n%C %Z%n%S'], + ['NI', '%N%n%O%n%A%n%Z%n%C, %S'], + ['NL', '%O%n%N%n%A%n%Z %C'], + ['NO', '%N%n%O%n%A%n%Z %C'], + ['NP', '%N%n%O%n%A%n%C %Z'], + ['NR', '%N%n%O%n%A%n%S'], + ['NZ', '%N%n%O%n%A%n%D%n%C %Z'], + ['OM', '%N%n%O%n%A%n%Z%n%C'], + ['PA', '%N%n%O%n%A%n%C%n%S'], + ['PE', '%N%n%O%n%A%n%C %Z%n%S'], + ['PF', '%N%n%O%n%A%n%Z %C %S'], + ['PG', '%N%n%O%n%A%n%C %Z %S'], + ['PH', '%N%n%O%n%A%n%D, %C%n%Z %S'], + ['PK', '%N%n%O%n%A%n%C-%Z'], + ['PL', '%N%n%O%n%A%n%Z %C'], + ['PM', '%O%n%N%n%A%n%Z %C %X'], + ['PN', '%N%n%O%n%A%n%C%n%Z'], + ['PR', '%N%n%O%n%A%n%C PR %Z'], + ['PT', '%N%n%O%n%A%n%Z %C'], + ['PW', '%N%n%O%n%A%n%C %S %Z'], + ['PY', '%N%n%O%n%A%n%Z %C'], + ['RE', '%O%n%N%n%A%n%Z %C %X'], + ['RO', '%N%n%O%n%A%n%Z %C'], + ['RS', '%N%n%O%n%A%n%Z %C'], + ['RU', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['SA', '%N%n%O%n%A%n%C %Z'], + ['SC', '%N%n%O%n%A%n%C%n%S'], + ['SD', '%N%n%O%n%A%n%C%n%Z'], + ['SE', '%O%n%N%n%A%nSE-%Z %C'], + ['SG', '%N%n%O%n%A%nSINGAPORE %Z'], + ['SH', '%N%n%O%n%A%n%C%n%Z'], + ['SI', '%N%n%O%n%A%nSI-%Z %C'], + ['SJ', '%N%n%O%n%A%n%Z %C'], + ['SK', '%N%n%O%n%A%n%Z %C'], + ['SM', '%N%n%O%n%A%n%Z %C'], + ['SN', '%N%n%O%n%A%n%Z %C'], + ['SO', '%N%n%O%n%A%n%C, %S %Z'], + ['SR', '%N%n%O%n%A%n%C%n%S'], + ['SV', '%N%n%O%n%A%n%Z-%C%n%S'], + ['SZ', '%N%n%O%n%A%n%C%n%Z'], + ['TA', '%N%n%O%n%A%n%C%n%Z'], + ['TC', '%N%n%O%n%A%n%C%n%Z'], + ['TH', '%N%n%O%n%A%n%D %C%n%S %Z'], + ['TJ', '%N%n%O%n%A%n%Z %C'], + ['TM', '%N%n%O%n%A%n%Z %C'], + ['TN', '%N%n%O%n%A%n%Z %C'], + ['TR', '%N%n%O%n%A%n%Z %C/%S'], + ['TV', '%N%n%O%n%A%n%C%n%S'], + ['TW', '%Z%n%S%C%n%A%n%O%n%N'], + ['TZ', '%N%n%O%n%A%n%Z %C'], + ['UA', '%N%n%O%n%A%n%C%n%S%n%Z'], + ['UM', '%N%n%O%n%A%n%C %S %Z'], + ['US', '%N%n%O%n%A%n%C, %S %Z'], + ['UY', '%N%n%O%n%A%n%Z %C %S'], + ['UZ', '%N%n%O%n%A%n%Z %C%n%S'], + ['VA', '%N%n%O%n%A%n%Z %C'], + ['VC', '%N%n%O%n%A%n%C %Z'], + ['VE', '%N%n%O%n%A%n%C %Z, %S'], + ['VG', '%N%n%O%n%A%n%C%n%Z'], + ['VI', '%N%n%O%n%A%n%C %S %Z'], + ['VN', '%N%n%O%n%A%n%C%n%S %Z'], + ['WF', '%O%n%N%n%A%n%Z %C %X'], + ['XK', '%N%n%O%n%A%n%Z %C'], + ['YT', '%O%n%N%n%A%n%Z %C %X'], + ['ZA', '%N%n%O%n%A%n%D%n%C%n%Z'], + ['ZM', '%N%n%O%n%A%n%Z %C'], + ]); + const defaultAddressFormat = '%N%n%O%n%A%n%C'; + + const getFormatString = (countryCode) => { + var _a; + return (_a = addressFormats.get(countryCode.toUpperCase())) !== null && _a !== void 0 ? _a : defaultAddressFormat; + }; + const getFormatSubstrings = (format) => { + const parts = []; + let escaped = false; + let currentLiteral = ''; + for (const char of format) { + if (escaped) { + escaped = false; + parts.push(`%${char}`); + continue; + } + if (char !== '%') { + currentLiteral += char; + continue; + } + if (currentLiteral.length > 0) { + parts.push(currentLiteral); + currentLiteral = ''; + } + escaped = true; + } + if (currentLiteral.length > 0) { + parts.push(currentLiteral); + } + return parts; + }; + const fields = new Map([ + ['%N', 'name'], + ['%O', 'organization'], + ['%A', 'addressLines'], + ['%D', 'dependentLocality'], + ['%C', 'locality'], + ['%S', 'administrativeArea'], + ['%Z', 'postalCode'], + ['%X', 'sortingCode'], + ['%R', 'postalCountry'], + ]); + const getFieldForFormatSubstring = (formatSubstring) => { + const field = fields.get(formatSubstring); + /* istanbul ignore next imported format strings should never contain invalid substrings */ + if (!field) { + throw new Error(`Could not find field for format substring ${formatSubstring}`); + } + return field; + }; + const addressHasValueForField = (address, field) => { + if (field === 'addressLines') { + return address.addressLines !== undefined && address.addressLines.length > 0; + } + return address[field] !== undefined && address[field] !== ''; + }; + const formatSubstringRepresentsField = (formatSubstring) => { + return formatSubstring !== '%n' && formatSubstring.startsWith('%'); + }; + const pruneFormat = (formatSubstrings, address) => { + const prunedFormat = []; + for (const [i, formatSubstring] of formatSubstrings.entries()) { + // Always keep the newlines. + if (formatSubstring === '%n') { + prunedFormat.push(formatSubstring); + continue; + } + if (formatSubstringRepresentsField(formatSubstring)) { + // Always keep non-empty address fields. + if (addressHasValueForField(address, getFieldForFormatSubstring(formatSubstring))) { + prunedFormat.push(formatSubstring); + } + continue; + } + // Only keep literals that satisfy these two conditions: + // 1. Not preceding an empty field. + // 2. Not following a removed field. + if ((i === formatSubstrings.length - 1 + || formatSubstrings[i + 1] === '%n' + || addressHasValueForField(address, getFieldForFormatSubstring(formatSubstrings[i + 1]))) && (i === 0 + || !formatSubstringRepresentsField(formatSubstrings[i - 1]) + || (prunedFormat.length > 0 && formatSubstringRepresentsField(prunedFormat[prunedFormat.length - 1])))) { + prunedFormat.push(formatSubstring); + } + } + return prunedFormat; + }; + const formatAddress = (address) => { + var _a; + const formatString = getFormatString((_a = address.postalCountry) !== null && _a !== void 0 ? _a : 'ZZ'); + const formatSubstrings = getFormatSubstrings(formatString); + const prunedFormat = pruneFormat(formatSubstrings, address); + const lines = []; + let currentLine = ''; + for (const formatSubstring of prunedFormat) { + if (formatSubstring === '%n') { + if (currentLine.length > 0) { + lines.push(currentLine); + currentLine = ''; + } + continue; + } + if (!formatSubstringRepresentsField(formatSubstring)) { + // Not a symbol we recognize, so must be a literal. We append it unchanged. + currentLine += formatSubstring; + continue; + } + const field = getFieldForFormatSubstring(formatSubstring); + /* istanbul ignore next imported format strings should never contain the postal country */ + if (field === 'postalCountry') { + // Country name is treated separately. + continue; + } + if (field === 'addressLines') { + // The field "address lines" represents the address lines of an address, so there can be multiple values. + // It is safe to assert addressLines to be defined here, as the pruning process already checked for that. + const addressLines = address.addressLines.filter(addressLine => addressLine !== ''); + if (addressLines.length === 0) { + // Empty address lines are ignored. + continue; + } + currentLine += addressLines[0]; + if (addressLines.length > 1) { + lines.push(currentLine); + currentLine = ''; + lines.push(...addressLines.slice(1)); + } + continue; + } + // Any other field can be appended as is. + currentLine += address[field]; + } + if (currentLine.length > 0) { + lines.push(currentLine); + } + return lines; + }; + + exports.formatAddress = formatAddress; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); +//# sourceMappingURL=index.umd.js.map diff --git a/dist/index.umd.js.map b/dist/index.umd.js.map new file mode 100644 index 0000000..bc23f01 --- /dev/null +++ b/dist/index.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.umd.js","sources":["../src/addressFormats.ts","../src/formatAddress.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;;;IAAA;IAEA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAiB;QAC3C,CAAC,IAAI,EAAE,oBAAoB,CAAC;QAC5B,CAAC,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