@transportme/vline-nsp-reader 1.0.6 → 1.0.8

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.
@@ -32,7 +32,8 @@ export default class PassPDFReader {
32
32
  let currentRun = {
33
33
  type: '',
34
34
  stops: [],
35
- operationDay
35
+ operationDay,
36
+ flags: ''
36
37
  }
37
38
 
38
39
  let lastStation
@@ -43,7 +44,10 @@ export default class PassPDFReader {
43
44
  currentRun.type = stopData[0] + stopData.slice(1).toLowerCase()
44
45
  continue
45
46
  }
46
- if (stationName === 'Service Information') continue
47
+ if (stationName === 'Service Information') {
48
+ currentRun.flags = stopData || ''
49
+ continue
50
+ }
47
51
  if (!stopData || stopData.length === 1) continue
48
52
  if (stationName === 'Change Service' && !currentRun.stops.length) continue
49
53
  if (stationName === 'Change Service' && stopData.length) {
@@ -53,7 +57,8 @@ export default class PassPDFReader {
53
57
  currentRun = {
54
58
  type: stopData[0] + stopData.slice(1).toLowerCase(),
55
59
  stops: [],
56
- operationDay
60
+ operationDay,
61
+ flags: ''
57
62
  }
58
63
 
59
64
  continue
@@ -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.6",
3
+ "version": "1.0.8",
4
4
  "main": "lib.mjs",
5
5
  "scripts": {
6
6
  "test": "mocha './{,!(node_modules)/**}/*.test.mjs'"