@furkot/address
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,2 +0,2 @@ | ||
const { abbr2country, country2abbr } = require('../country'); | ||
const { country2abbr } = require('../country'); | ||
const { abbr2state, state2abbr, state2country } = require('../state'); | ||
@@ -17,3 +17,3 @@ | ||
if (!address) { | ||
return ; | ||
return address; | ||
} | ||
@@ -35,5 +35,2 @@ | ||
} | ||
else if (!abbr2country[country]) { | ||
return; | ||
} | ||
} | ||
@@ -40,0 +37,0 @@ state = getState(state); |
@@ -9,4 +9,3 @@ module.exports = stringify; | ||
state2abbr, | ||
state2country, | ||
country2states | ||
state2country | ||
} = require('../state'); | ||
@@ -26,5 +25,14 @@ | ||
* | ||
* stringify({ house: 1, street: 'street', province: 'province'}); | ||
* // => '1 street,,province,' | ||
* | ||
* stringify({ house: 1, town: 'town', country: 'country' }); | ||
* // => ',town,,country' | ||
* // => '1,town,,country' | ||
* | ||
* stringify({ street: 'street', town: 'town' }); | ||
* // => 'street,town,,' | ||
* | ||
* * stringify({}); | ||
* // => '' | ||
* | ||
* stringify(); | ||
@@ -40,30 +48,18 @@ * // => undefined | ||
country = country2abbr[country] || country; | ||
province = state2abbr[province] || province; | ||
if (!country) { | ||
if (!province) { // if state or country is missing | ||
return; | ||
} | ||
province = state2abbr[province] || province; | ||
country = state2country[province]; | ||
if (!country) { | ||
return; | ||
} | ||
} | ||
else { | ||
province = state2abbr[province] || province; | ||
country = country2abbr[country] || country; | ||
} | ||
const st = country2states[country]; | ||
if (st && !st[province]) { | ||
province = ''; | ||
if (house) { | ||
if (street) { | ||
street = [house, street].join(' '); | ||
} | ||
else { | ||
street = house; | ||
} | ||
} | ||
if (house && street) { | ||
street = [house, street].join(' '); | ||
} | ||
else if (house) { | ||
street = `${house}`; | ||
} | ||
return [street, town, province, country].map(p => p ?? '').join(',').replace(/^,+/, ''); | ||
} |
{ | ||
"name": "@furkot/address", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Furkot address normalizer.", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16289
615