diff options
author | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-13 14:29:27 +1000 |
---|---|---|
committer | Andrew Harvey <andrew@alantgeo.com.au> | 2021-05-13 14:29:27 +1000 |
commit | 6853fd209fa80f8788951e6105ccfe8e5c8b30c6 (patch) | |
tree | ced7bbae5cdc5bbf1ab1d3d3d92bd8956c0a77ca /lib | |
parent | 9e2c8a7a3964363b12559c91ea55d9f80659fa11 (diff) |
additional logging
Diffstat (limited to 'lib')
-rw-r--r-- | lib/unitsToRanges.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/unitsToRanges.js b/lib/unitsToRanges.js index 11e867f..cd572f7 100644 --- a/lib/unitsToRanges.js +++ b/lib/unitsToRanges.js @@ -6,10 +6,11 @@ * 1,2,3a-5a => 1-2;3a-5a * * @param {Array} units + * @param {Array} [sourceAddresses] - the source addresses where these units came from, used for debugging * * @returns {string} addr:flats list */ -module.exports = (units) => { +module.exports = (units, sourceAddresses) => { const regexp = /^(?<pre>\D*)(?<num>\d*)(?<suf>\D*)$/ // expand out any existing ranges which may be mixed into the input @@ -30,11 +31,17 @@ module.exports = (units) => { } else { // prefix/suffix don't match in the from-to, so just pass as is console.log(`passed a range with different prefix/suffix: ${rangeParts[0]}-${rangeParts[1]}`) + if (sourceAddresses) { + console.log(JSON.stringify(sourceAddresses, null, 2)) + } acc.push(cur) } } else if (rangeParts.length > 2) { // 1-2-3 not sure if this ever occures, but just pass as is console.log(`Unsupported range ${cur}`) + if (sourceAddresses) { + console.log(JSON.stringify(sourceAddresses, null, 2)) + } acc.push(cur) } else { // was not a range @@ -65,6 +72,9 @@ module.exports = (units) => { if (!curParts) { console.log(`"${cur}" didn't match regexp for prefix number suffix`) + if (sourceAddresses) { + console.log(JSON.stringify(sourceAddresses, null, 2)) + } return acc } |