minotor 7.0.1 → 7.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minotor",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "description": "A lightweight client-side transit routing library.",
5
5
  "keywords": [
6
6
  "minotor",
@@ -190,6 +190,10 @@ export class Router {
190
190
  options.transportModes,
191
191
  );
192
192
  markedStops.clear();
193
+ const earliestArrivalAtAnyDestination = this.earliestArrivalAtAnyStop(
194
+ earliestArrivals,
195
+ destinations,
196
+ );
193
197
  // for each route that can be reached with at least round - 1 trips
194
198
  const reachableRoutesArray = Array.from(reachableRoutes.entries());
195
199
  for (let i = 0; i < reachableRoutesArray.length; i++) {
@@ -214,9 +218,7 @@ export class Router {
214
218
  if (
215
219
  currentDropOffType !== 'NOT_AVAILABLE' &&
216
220
  currentArrivalTime.isBefore(earliestArrivalAtCurrentStop) &&
217
- currentArrivalTime.isBefore(
218
- this.earliestArrivalAtAnyStop(earliestArrivals, destinations),
219
- )
221
+ currentArrivalTime.isBefore(earliestArrivalAtAnyDestination)
220
222
  ) {
221
223
  const bestHopOnDepartureTime = route.departureFrom(
222
224
  currentTrip.bestHopOnStop,
@@ -193,9 +193,16 @@ export class Time {
193
193
  if (times.length === 0) {
194
194
  throw new Error('At least one Time instance is required.');
195
195
  }
196
- return times.reduce((maxTime, currentTime) => {
197
- return currentTime.isAfter(maxTime) ? currentTime : maxTime;
198
- });
196
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
197
+ let maxTime = times[0]!;
198
+ for (let i = 1; i < times.length; i++) {
199
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
200
+ if (times[i]!.minutesSinceMidnight > maxTime.minutesSinceMidnight) {
201
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
202
+ maxTime = times[i]!;
203
+ }
204
+ }
205
+ return maxTime;
199
206
  }
200
207
 
201
208
  /**
@@ -208,9 +215,16 @@ export class Time {
208
215
  if (times.length === 0) {
209
216
  throw new Error('At least one Time instance is required.');
210
217
  }
211
- return times.reduce((minTime, currentTime) => {
212
- return currentTime.isBefore(minTime) ? currentTime : minTime;
213
- });
218
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
219
+ let minTime = times[0]!;
220
+ for (let i = 1; i < times.length; i++) {
221
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
222
+ if (times[i]!.minutesSinceMidnight < minTime.minutesSinceMidnight) {
223
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
224
+ minTime = times[i]!;
225
+ }
226
+ }
227
+ return minTime;
214
228
  }
215
229
 
216
230
  /**
@@ -220,7 +234,7 @@ export class Time {
220
234
  * @returns True if the current Time instance is after the other Time instance, otherwise false.
221
235
  */
222
236
  isAfter(otherTime: Time): boolean {
223
- return this.minutesSinceMidnight > otherTime.toMinutes();
237
+ return this.minutesSinceMidnight > otherTime.minutesSinceMidnight;
224
238
  }
225
239
 
226
240
  /**
@@ -230,7 +244,7 @@ export class Time {
230
244
  * @returns True if the current Time instance is before the other Time instance, otherwise false.
231
245
  */
232
246
  isBefore(otherTime: Time): boolean {
233
- return this.minutesSinceMidnight < otherTime.toMinutes();
247
+ return this.minutesSinceMidnight < otherTime.minutesSinceMidnight;
234
248
  }
235
249
 
236
250
  /**
@@ -240,6 +254,6 @@ export class Time {
240
254
  * @returns True if the current Time instance is equal to the other Time instance, otherwise false.
241
255
  */
242
256
  equals(otherTime: Time): boolean {
243
- return this.minutesSinceMidnight === otherTime.toMinutes();
257
+ return this.minutesSinceMidnight === otherTime.minutesSinceMidnight;
244
258
  }
245
259
  }
@@ -184,9 +184,7 @@ export class Timetable {
184
184
  `Service route not found for route ID: ${route.serviceRoute()}`,
185
185
  );
186
186
  }
187
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
188
- const { routes, ...serviceRouteInfo } = serviceRoute;
189
- return serviceRouteInfo;
187
+ return { type: serviceRoute.type, name: serviceRoute.name };
190
188
  }
191
189
 
192
190
  /**