gtfs-to-html 2.2.0 → 2.3.2

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.
@@ -31,7 +31,10 @@ export function timetablePageHasDifferentDays(timetablePage) {
31
31
  return true;
32
32
  }
33
33
 
34
- return timetable.dayListLong === timetablePage.consolidatedTimetables[idx - 1].dayListLong;
34
+ return (
35
+ timetable.dayListLong ===
36
+ timetablePage.consolidatedTimetables[idx - 1].dayListLong
37
+ );
35
38
  });
36
39
  }
37
40
 
@@ -45,7 +48,10 @@ export function timetablePageHasDifferentLabels(timetablePage) {
45
48
  return true;
46
49
  }
47
50
 
48
- return timetable.timetable_label === timetablePage.consolidatedTimetables[idx - 1].timetable_label;
51
+ return (
52
+ timetable.timetable_label ===
53
+ timetablePage.consolidatedTimetables[idx - 1].timetable_label
54
+ );
49
55
  });
50
56
  }
51
57
 
@@ -53,34 +59,39 @@ export function timetablePageHasDifferentLabels(timetablePage) {
53
59
  * Discern if a timetable has any notes or notices to display.
54
60
  */
55
61
  export function hasNotesOrNotices(timetable) {
56
- return timetable.requestPickupSymbolUsed
57
- || timetable.noPickupSymbolUsed
58
- || timetable.requestDropoffSymbolUsed
59
- || timetable.noDropoffSymbolUsed
60
- || timetable.noServiceSymbolUsed
61
- || timetable.interpolatedStopSymbolUsed
62
- || timetable.notes.length > 0;
62
+ return (
63
+ timetable.requestPickupSymbolUsed ||
64
+ timetable.noPickupSymbolUsed ||
65
+ timetable.requestDropoffSymbolUsed ||
66
+ timetable.noDropoffSymbolUsed ||
67
+ timetable.noServiceSymbolUsed ||
68
+ timetable.interpolatedStopSymbolUsed ||
69
+ timetable.notes.length > 0
70
+ );
63
71
  }
64
72
 
65
73
  /*
66
74
  * Return an array of all timetable notes that relate to the entire timetable or route.
67
75
  */
68
76
  export function getNotesForTimetableLabel(notes) {
69
- return notes.filter(note => !note.stop_id && !note.trip_id);
77
+ return notes.filter((note) => !note.stop_id && !note.trip_id);
70
78
  }
71
79
 
72
80
  /*
73
81
  * Return an array of all timetable notes for a specific stop and stop_sequence.
74
82
  */
75
83
  export function getNotesForStop(notes, stop) {
76
- return notes.filter(note => {
84
+ return notes.filter((note) => {
77
85
  // Don't show if note applies only to a specific trip.
78
86
  if (note.trip_id) {
79
87
  return false;
80
88
  }
81
89
 
82
90
  // Don't show if note applies only to a specific stop_sequence that is not found.
83
- if (note.stop_sequence && !stop.trips.some(trip => trip.stop_sequence === note.stop_sequence)) {
91
+ if (
92
+ note.stop_sequence &&
93
+ !stop.trips.some((trip) => trip.stop_sequence === note.stop_sequence)
94
+ ) {
84
95
  return false;
85
96
  }
86
97
 
@@ -92,7 +103,7 @@ export function getNotesForStop(notes, stop) {
92
103
  * Return an array of all timetable notes for a specific trip.
93
104
  */
94
105
  export function getNotesForTrip(notes, trip) {
95
- return notes.filter(note => {
106
+ return notes.filter((note) => {
96
107
  // Don't show if note applies only to a specific stop.
97
108
  if (note.stop_id) {
98
109
  return false;
@@ -106,17 +117,69 @@ export function getNotesForTrip(notes, trip) {
106
117
  * Return an array of all timetable notes for a specific stoptime.
107
118
  */
108
119
  export function getNotesForStoptime(notes, stoptime) {
109
- return notes.filter(note => {
120
+ return notes.filter((note) => {
110
121
  // Show notes that apply to all trips at this stop if `show_on_stoptime` is true.
111
- if (!note.trip_id && note.stop_id === stoptime.stop_id && note.show_on_stoptime === 1) {
122
+ if (
123
+ !note.trip_id &&
124
+ note.stop_id === stoptime.stop_id &&
125
+ note.show_on_stoptime === 1
126
+ ) {
112
127
  return true;
113
128
  }
114
129
 
115
130
  // Show notes that apply to all stops of this trip if `show_on_stoptime` is true.
116
- if (!note.stop_id && note.trip_id === stoptime.trip_id && note.show_on_stoptime === 1) {
131
+ if (
132
+ !note.stop_id &&
133
+ note.trip_id === stoptime.trip_id &&
134
+ note.show_on_stoptime === 1
135
+ ) {
117
136
  return true;
118
137
  }
119
138
 
120
- return note.trip_id === stoptime.trip_id && note.stop_id === stoptime.stop_id;
139
+ return (
140
+ note.trip_id === stoptime.trip_id && note.stop_id === stoptime.stop_id
141
+ );
121
142
  });
122
143
  }
144
+
145
+ /*
146
+ * Formats a trip name.
147
+ */
148
+ export function formatTripName(trip, index, timetable) {
149
+ let tripName = '';
150
+ if (timetable.routes.length > 1) {
151
+ tripName = trip.route_short_name;
152
+ } else if (trip.trip_short_name) {
153
+ tripName += trip.trip_short_name;
154
+ } else {
155
+ tripName += `Run #${index + 1}`;
156
+ }
157
+
158
+ if (timetableHasDifferentDays(timetable)) {
159
+ tripName += ` ${trip.dayList}`;
160
+ }
161
+
162
+ return tripName;
163
+ }
164
+
165
+ /*
166
+ * Formats a trip name.
167
+ */
168
+ export function formatTripNameForCSV(trip, timetable) {
169
+ let tripName = '';
170
+ if (timetable.routes.length > 1) {
171
+ tripName += `${trip.route_short_name} - `;
172
+ }
173
+
174
+ if (trip.trip_short_name) {
175
+ tripName += trip.trip_short_name;
176
+ } else {
177
+ tripName += trip.trip_id;
178
+ }
179
+
180
+ if (timetableHasDifferentDays(timetable)) {
181
+ tripName += ` - ${trip.dayList}`;
182
+ }
183
+
184
+ return tripName;
185
+ }
package/lib/time-utils.js CHANGED
@@ -9,7 +9,7 @@ export function fromGTFSTime(timeString) {
9
9
  return moment({
10
10
  hour: duration.hours(),
11
11
  minute: duration.minutes(),
12
- second: duration.seconds()
12
+ second: duration.seconds(),
13
13
  });
14
14
  }
15
15
 
@@ -49,7 +49,15 @@ export function calendarToCalendarCode(c) {
49
49
  * Convert a string of 1s and 0s representing a weekday to an object.
50
50
  */
51
51
  export function calendarCodeToCalendar(code) {
52
- const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
52
+ const days = [
53
+ 'monday',
54
+ 'tuesday',
55
+ 'wednesday',
56
+ 'thursday',
57
+ 'friday',
58
+ 'saturday',
59
+ 'sunday',
60
+ ];
53
61
  const calendar = {};
54
62
 
55
63
  for (const [index, day] of days.entries()) {