@fragaria/address-formatter
Advanced tools
Comparing version 2.7.0 to 2.8.0
{ | ||
"name": "@fragaria/address-formatter", | ||
"version": "2.7.0", | ||
"version": "2.8.0", | ||
"description": "Universal international address formatting in Javascript", | ||
@@ -10,3 +10,4 @@ "main": "dist/cjs/address-formatter.js", | ||
"scripts": { | ||
"lint": "eslint src test", | ||
"lint": "semistandard src test", | ||
"lint:fix": "semistandard --fix src test", | ||
"test": "rimraf coverage && jest --coverage", | ||
@@ -39,3 +40,2 @@ "test:ci": "rimraf coverage && jest --coverage --ci", | ||
"@babel/core": "^7.8.6", | ||
"@babel/eslint-parser": "^7.16.3", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
@@ -45,12 +45,10 @@ "@babel/plugin-proposal-object-rest-spread": "^7.8.3", | ||
"@babel/preset-env": "^7.8.6", | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"@rollup/plugin-commonjs": "^21.0.1", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.1.2", | ||
"babel-jest": "^27.4.1", | ||
"babel-loader": "^8.2.3", | ||
"coveralls": "^3.0.9", | ||
"eslint": "^8.4.0", | ||
"eslint-config-standard": "^16.0.0", | ||
"eslint-plugin-import": "^2.19.1", | ||
"eslint-plugin-jest": "^25.2.1", | ||
"eslint-plugin-node": "^11.0.0", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"eslint": "^8.6.0", | ||
"jest": "^27.0.1", | ||
@@ -60,11 +58,13 @@ "js-yaml": "^4.0.0", | ||
"rollup": "^2.0.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-json": "^4.0.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^7.0.0" | ||
"rollup-plugin-terser": "^7.0.0", | ||
"semistandard": "^16.0.1" | ||
}, | ||
"engines": { | ||
"node": ">=12.0.0" | ||
"node": ">=14.0.0" | ||
}, | ||
"semistandard": { | ||
"env": [ | ||
"jest" | ||
] | ||
}, | ||
"jest": { | ||
@@ -71,0 +71,0 @@ "testRegex": "./test/.*.spec.js", |
@@ -11,3 +11,3 @@ const internal = require('./internal.js'); | ||
fallbackCountryCode: undefined, | ||
output: 'string', | ||
output: 'string' | ||
}) => { | ||
@@ -32,3 +32,3 @@ let realInput = Object.assign({}, input); | ||
return result; | ||
}, | ||
} | ||
}; |
@@ -11,2 +11,13 @@ const Mustache = require('mustache'); | ||
const VALID_REPLACEMENT_COMPONENTS = ['state']; | ||
const SMALL_DISTRICT_COUNTRIES = { | ||
BR: 1, | ||
CR: 1, | ||
ES: 1, | ||
NI: 1, | ||
PY: 1, | ||
RO: 1, | ||
TG: 1, | ||
TM: 1, | ||
XK: 1 | ||
}; | ||
@@ -49,3 +60,3 @@ const determineCountryCode = (input, fallbackCountryCode = null) => { | ||
} | ||
if (countryCode === 'NL' && input.state) { | ||
@@ -85,4 +96,10 @@ if (input.state === 'Curaçao') { | ||
const inputKeys = Object.keys(input); | ||
let tailoredAliases = aliases; | ||
if (!SMALL_DISTRICT_COUNTRIES[input.country_code]) { | ||
tailoredAliases = aliases.filter((a) => a.alias !== 'district'); | ||
tailoredAliases.push({ alias: 'district', name: 'state_district' }); | ||
} | ||
for (let i = 0; i < inputKeys.length; i++) { | ||
const alias = aliases.find((a) => a.alias === inputKeys[i]); | ||
const alias = tailoredAliases.find((a) => a.alias === inputKeys[i]); | ||
if (alias && !input[alias.name]) { | ||
@@ -102,3 +119,3 @@ input[alias.name] = input[alias.alias]; | ||
const found = stateCodes[countryCode].find((e) => { | ||
if (typeof e.name == 'string' && e.name.toUpperCase() === state.toUpperCase()) { | ||
if (typeof e.name === 'string' && e.name.toUpperCase() === state.toUpperCase()) { | ||
return e; | ||
@@ -110,3 +127,3 @@ } | ||
return { | ||
key: e.key, | ||
key: e.key | ||
}; | ||
@@ -125,3 +142,3 @@ } | ||
const found = countyCodes[countryCode].find((e) => { | ||
if (typeof e.name == 'string' && e.name.toUpperCase() === county.toUpperCase()) { | ||
if (typeof e.name === 'string' && e.name.toUpperCase() === county.toUpperCase()) { | ||
return e; | ||
@@ -133,3 +150,3 @@ } | ||
return { | ||
key: e.key, | ||
key: e.key | ||
}; | ||
@@ -212,3 +229,3 @@ } | ||
new RegExp(`\\b${abbreviations[lang][j].replacements[k].src}\\b`), | ||
abbreviations[lang][j].replacements[k].dest, | ||
abbreviations[lang][j].replacements[k].dest | ||
); | ||
@@ -221,3 +238,3 @@ } | ||
} | ||
// naive url cleanup, keys might have changed along the cleanup | ||
@@ -267,3 +284,3 @@ inputKeys = Object.keys(input); | ||
{ s: /\n[ \t]+/u, d: '\n' }, // newline plus space to newline | ||
{ s: /\n\n+/u, d: '\n' }, // multiple newline to one | ||
{ s: /\n\n+/u, d: '\n' } // multiple newline to one | ||
]; | ||
@@ -307,3 +324,3 @@ const dedupe = (inputChunks, glue, modifier = (s) => s) => { | ||
}; | ||
}, | ||
} | ||
}); | ||
@@ -339,3 +356,3 @@ | ||
cleanupRender, | ||
renderTemplate, | ||
renderTemplate | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
19
1095212
37335