@transportme/vline-nsp-reader 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,7 +41,7 @@ export default class PassPDFReader {
41
41
  const stationName = stations[stationIndex]
42
42
  const stopData = (body[stationIndex][columnIndex] || '').replace('.', ':')
43
43
  if (stationName === 'Service') {
44
- currentRun.type = stopData[0] + stopData.slice(1).toLowerCase()
44
+ currentRun.type = stopData[0] ? stopData[0] + stopData.slice(1).toLowerCase() : null
45
45
  continue
46
46
  }
47
47
  if (stationName === 'Service Information') {
@@ -81,7 +81,7 @@ export default class PassPDFReader {
81
81
  }
82
82
  }
83
83
 
84
- return runs.map(run => this.setRunData(run))
84
+ return runs.filter(run => run.type).map(run => this.setRunData(run))
85
85
  }
86
86
 
87
87
  setRunData(run) {
@@ -78,6 +78,11 @@ export default class PassTableReader {
78
78
  }
79
79
  }
80
80
 
81
+ // Remove empty rows
82
+ for (let y = tableData.length - 1; y > 0; y--) {
83
+ if (tableData[y].length === 0) tableData.splice(y, 1)
84
+ }
85
+
81
86
  const colCount = tableData[1].length
82
87
  for (let x = colCount - 1; x > 0; x--) {
83
88
  let text = tableData[0][x] || ''
@@ -91,6 +96,11 @@ export default class PassTableReader {
91
96
  if (!tableData[0][x]) tableData[0][x] = tableData[0][x - 1]
92
97
  }
93
98
 
99
+ for (let x = colCount - 1; x > 0; x--) {
100
+ let hasNonEmpty = tableData.slice(1).some(row => row[x] && row[x].length > 0)
101
+ if (!hasNonEmpty) tableData.forEach(row => row.splice(x, 1))
102
+ }
103
+
94
104
  return tableData
95
105
  })
96
106
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transportme/vline-nsp-reader",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "main": "lib.mjs",
5
5
  "scripts": {
6
6
  "test": "mocha './{,!(node_modules)/**}/*.test.mjs'"