-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc12b0b
commit f27bfb1
Showing
15 changed files
with
276 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
function variables(data) { | ||
// DAD variables | ||
const addressDirectory = 'dad/src/addresses' | ||
const fileExtension = '-addresses.min.json' | ||
const australiaDirectory = 'australia' | ||
const canadaDirectory = 'canada' | ||
const chinaDirectory = 'china' | ||
const europeDirectory = 'europe' | ||
const mexicoDirectory = 'mexico' | ||
const unitedStatesDirectory = 'united-states/' | ||
const invalidTagErrorMessage = 'Data source tag was not valid. An address could not be retrieved.' | ||
let dataFilePath = null | ||
|
||
|
||
// Country variables | ||
const dataFilePaths = { | ||
// Australia | ||
'AU_VT': `${addressDirectory}/${australiaDirectory}/vt${fileExtension}`, | ||
// Canada | ||
'CA_BC': `${addressDirectory}/${canadaDirectory}/bc${fileExtension}`, | ||
// China | ||
'CN_BJ': `${addressDirectory}/${chinaDirectory}/bj${fileExtension}`, | ||
'CN_HK': `${addressDirectory}/${chinaDirectory}/hk${fileExtension}`, | ||
// Europe | ||
'EU_DE': `${addressDirectory}/${europeDirectory}/de${fileExtension}`, | ||
'EU_ES': `${addressDirectory}/${europeDirectory}/es${fileExtension}`, | ||
'EU_UK': `${addressDirectory}/${europeDirectory}/uk${fileExtension}`, | ||
// Mexico | ||
'MX_MX': `${addressDirectory}/${mexicoDirectory}/mx${fileExtension}`, | ||
// United States | ||
'US_AZ': `${addressDirectory}/${unitedStatesDirectory}/az${fileExtension}`, | ||
'US_CA': `${addressDirectory}/${unitedStatesDirectory}/ca${fileExtension}`, | ||
'US_ID': `${addressDirectory}/${unitedStatesDirectory}/id${fileExtension}`, | ||
'US_KS': `${addressDirectory}/${unitedStatesDirectory}/ks${fileExtension}`, | ||
'US_NV': `${addressDirectory}/${unitedStatesDirectory}/nv${fileExtension}`, | ||
'US_NY': `${addressDirectory}/${unitedStatesDirectory}/ny${fileExtension}`, | ||
'US_OR': `${addressDirectory}/${unitedStatesDirectory}/or${fileExtension}`, | ||
'US_TX': `${addressDirectory}/${unitedStatesDirectory}/tx${fileExtension}`, | ||
'US_UT': `${addressDirectory}/${unitedStatesDirectory}/ut${fileExtension}`, | ||
'US_WA': `${addressDirectory}/${unitedStatesDirectory}/wa${fileExtension}`, | ||
// Invalid data source tag | ||
'invalid': null, | ||
} | ||
|
||
dataFilePath = dataFilePaths[data.toUpperCase()] || dataFilePaths['invalid'] | ||
|
||
if (dataFilePath === null) { | ||
throw new Error(invalidTagErrorMessage) | ||
} | ||
|
||
return dataFilePath | ||
} | ||
|
||
exports.variables = variables |
Oops, something went wrong.