minotor 12.0.1 → 13.0.0

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/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
- ## [12.0.1](https://github.com/aubryio/minotor/compare/v12.0.0...v12.0.1) (2026-10-24)
1
+ # [13.0.0](https://github.com/aubryio/minotor/compare/v12.0.1...v13.0.0) (2026-10-30)
2
2
 
3
3
 
4
- ### Performance Improvements
4
+ ### Code Refactoring
5
5
 
6
- * memory quick wins (reduce retained buffers, array allocations, etc.) ([#80](https://github.com/aubryio/minotor/issues/80)) ([d8371f6](https://github.com/aubryio/minotor/commit/d8371f6150b328c00cc9466e057bebf5cac0a8a0))
6
+ * improve public results APIs ([#81](https://github.com/aubryio/minotor/issues/81)) ([bc45e33](https://github.com/aubryio/minotor/commit/bc45e3345bbcfb57210cad0bd2ee748abfc5f8fe))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * result and rangeResult public API changes (routingGraph not accessible anymore,
12
+ harmonized methods signatures)
package/README.md CHANGED
@@ -126,6 +126,8 @@ const route = result.bestRoute(); // Route | undefined
126
126
 
127
127
  // Earliest arrival at any individual stop (useful for isochrone computation)
128
128
  const arrival = result.arrivalAt(stop.id); // { arrival: Time, legNumber: number } | undefined
129
+ // Earliest arrival at every reachable stop
130
+ const arrivals = result.arrivals();
129
131
  ```
130
132
 
131
133
  Query options:
@@ -166,11 +168,12 @@ for (const { departureTime, result } of rangeResult) {
166
168
  const earliest = rangeResult.bestRoute(); // earliest arrival
167
169
  const latest = rangeResult.latestDepartureRoute(); // latest possible departure
168
170
  const fastest = rangeResult.fastestRoute(); // shortest travel duration
169
- const all = rangeResult.getRoutes(); // all routes, earliest-departure-first
171
+ const all = rangeResult.routes(); // lazy iterator, earliest-departure-first
170
172
 
171
- // Earliest arrival at every reachable stop across all runs
172
- const arrivals = rangeResult.allEarliestArrivals(); // Map<StopId, Arrival>
173
- const durations = rangeResult.allShortestDurations(); // Map<StopId, DurationArrival>
173
+ // Earliest arrival at every reachable stop
174
+ const arrivals = rangeResult.arrivals();
175
+ // Shortest duration to every reachable stop
176
+ const durations = rangeResult.shortestDurations();
174
177
  ```
175
178
 
176
179
  ### CLI Usage
@@ -87,18 +87,18 @@ export declare const testBestRoutePerformance: (router: Router, tasks: Query[],
87
87
  */
88
88
  export declare const testRangeRouterPerformance: (router: Router, tasks: RangeQuery[], iterations: number, stopsIndex: StopsIndex) => PerformanceResult[];
89
89
  /**
90
- * Benchmarks {@link RangeResult.getRoutes} — the full Pareto-frontier
90
+ * Benchmarks {@link RangeResult.routes} — the full Pareto-frontier
91
91
  * reconstruction phase — independently of the range routing phase.
92
92
  *
93
93
  * @param router - The router instance used to produce the range results that
94
- * are then fed into `getRoutes`.
94
+ * are then fed into `routes`.
95
95
  * @param tasks - The list of range queries to benchmark. One
96
96
  * {@link PerformanceResult} is produced per query.
97
- * @param iterations - Number of times `getRoutes` is called per query.
97
+ * @param iterations - Number of times `routes` is fully consumed per query.
98
98
  * @param stopsIndex - Used to resolve stop names for result labels.
99
99
  * @returns An array of {@link PerformanceResult} objects, one per query, each
100
100
  * containing the mean wall-clock time (µs) and mean heap and ArrayBuffer deltas (MiB) for the
101
- * `getRoutes` call alone.
101
+ * full `routes` iteration alone.
102
102
  */
103
103
  export declare const testRangeResultPerformance: (router: Router, tasks: RangeQuery[], iterations: number, stopsIndex: StopsIndex) => PerformanceResult[];
104
104
  /**
package/dist/cli.mjs CHANGED
@@ -61,6 +61,19 @@ function __asyncValues(o) {
61
61
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
62
62
  }
63
63
 
64
+ function __classPrivateFieldGet(receiver, state, kind, f) {
65
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
66
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
67
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
68
+ }
69
+
70
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
71
+ if (kind === "m") throw new TypeError("Private method is not writable");
72
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
73
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
74
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
75
+ }
76
+
64
77
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
65
78
  var e = new Error(message);
66
79
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -21999,6 +22012,11 @@ class StraightLineTransferGenerator {
21999
22012
  }
22000
22013
  }
22001
22014
 
22015
+ /** Internal plotter access; deliberately not exported from the package entry point. */
22016
+ const resultGraph = Symbol('resultGraph');
22017
+ /** Internal access to query destinations for range result selection. */
22018
+ const resultDestinations = Symbol('resultDestinations');
22019
+
22002
22020
  /**
22003
22021
  * Configuration for DOT graph styling.
22004
22022
  */
@@ -22204,8 +22222,9 @@ class Plotter {
22204
22222
  */
22205
22223
  getStationInfo(stopId) {
22206
22224
  var _a;
22207
- const isOrigin = ((_a = this.result.routingState.graph[0]) === null || _a === void 0 ? void 0 : _a[stopId]) !== undefined;
22208
- const isDestination = this.result.routingState.destinations.includes(stopId);
22225
+ const { graph, destinations } = this.result[resultGraph]();
22226
+ const isOrigin = ((_a = graph[0]) === null || _a === void 0 ? void 0 : _a[stopId]) !== undefined;
22227
+ const isDestination = destinations.includes(stopId);
22209
22228
  return { isOrigin, isDestination };
22210
22229
  }
22211
22230
  /**
@@ -22355,7 +22374,7 @@ class Plotter {
22355
22374
  */
22356
22375
  collectStations() {
22357
22376
  const stations = new Set();
22358
- const graph = this.result.routingState.graph;
22377
+ const graph = this.result[resultGraph]().graph;
22359
22378
  for (const roundEdges of graph) {
22360
22379
  for (let stopId = 0; stopId < roundEdges.length; stopId++) {
22361
22380
  const edge = roundEdges[stopId];
@@ -22401,7 +22420,7 @@ class Plotter {
22401
22420
  collectEdges() {
22402
22421
  const edges = [];
22403
22422
  const continuationEdges = [];
22404
- const graph = this.result.routingState.graph;
22423
+ const graph = this.result[resultGraph]().graph;
22405
22424
  for (let round = 0; round < graph.length; round++) {
22406
22425
  const roundEdges = graph[round];
22407
22426
  if (!roundEdges)
@@ -22683,24 +22702,80 @@ class Route {
22683
22702
  }
22684
22703
  }
22685
22704
 
22705
+ var _Result_routingState;
22706
+ /**
22707
+ * A single-departure routing result.
22708
+ */
22686
22709
  class Result {
22687
- constructor(destinations, routingState, stopsIndex, timetable) {
22688
- this.destinations = destinations;
22689
- this.routingState = routingState;
22710
+ constructor(routingState, stopsIndex, timetable) {
22711
+ _Result_routingState.set(this, void 0);
22712
+ __classPrivateFieldSet(this, _Result_routingState, routingState, "f");
22690
22713
  this.stopsIndex = stopsIndex;
22691
22714
  this.timetable = timetable;
22692
22715
  }
22716
+ /** @internal Default query destinations for range result selection. */
22717
+ [(_Result_routingState = new WeakMap(), resultDestinations)]() {
22718
+ return __classPrivateFieldGet(this, _Result_routingState, "f").destinations;
22719
+ }
22720
+ /** @internal Routing graph and destination metadata for the graph plotter. */
22721
+ [resultGraph]() {
22722
+ return {
22723
+ graph: __classPrivateFieldGet(this, _Result_routingState, "f").graph,
22724
+ destinations: __classPrivateFieldGet(this, _Result_routingState, "f").destinations,
22725
+ };
22726
+ }
22727
+ /**
22728
+ * Iterates over reached stops, yielding each concrete stop ID, its earliest
22729
+ * arrival time, and the number of legs taken to reach it. Unreached stops
22730
+ * are omitted. Destination pruning may limit which stops were reached.
22731
+ * @param maxTransfers Optional transfer limit within retained data.
22732
+ */
22733
+ *arrivals(maxTransfers) {
22734
+ for (const reached of __classPrivateFieldGet(this, _Result_routingState, "f").arrivals()) {
22735
+ if (maxTransfers === undefined) {
22736
+ yield reached;
22737
+ }
22738
+ else {
22739
+ const arrival = this.concreteArrivalAt(reached.stop, maxTransfers);
22740
+ if (arrival !== undefined)
22741
+ yield Object.assign({ stop: reached.stop }, arrival);
22742
+ }
22743
+ }
22744
+ }
22745
+ /** Looks up one concrete stop without expanding equivalent stops. */
22746
+ concreteArrivalAt(stop, maxTransfers) {
22747
+ var _a;
22748
+ const best = __classPrivateFieldGet(this, _Result_routingState, "f").getArrival(stop);
22749
+ if (maxTransfers === undefined ||
22750
+ (best !== undefined && best.legNumber <= maxTransfers + 1)) {
22751
+ return best;
22752
+ }
22753
+ let earliest;
22754
+ const lastRound = Math.min(maxTransfers + 1, __classPrivateFieldGet(this, _Result_routingState, "f").graph.length - 1);
22755
+ for (let round = lastRound; round >= 0; round--) {
22756
+ const edge = (_a = __classPrivateFieldGet(this, _Result_routingState, "f").graph[round]) === null || _a === void 0 ? void 0 : _a[stop];
22757
+ if (edge !== undefined &&
22758
+ (earliest === undefined || edge.arrival < earliest.arrival)) {
22759
+ earliest = { arrival: edge.arrival, legNumber: round };
22760
+ }
22761
+ }
22762
+ return earliest;
22763
+ }
22693
22764
  /**
22694
22765
  * Expands a target stop or stop set to all equivalent concrete stop IDs.
22695
22766
  *
22696
- * When `to` is omitted, defaults to the resolved destinations stored on this
22697
- * result.
22767
+ * When `to` is omitted, defaults to the resolved destinations in the
22768
+ * query.
22698
22769
  *
22699
22770
  * Equivalent stops are expanded here so destination handling has a single
22700
22771
  * source of truth shared by route reconstruction and arrival lookups.
22701
22772
  */
22702
22773
  expandDestinations(to) {
22703
- const targets = to instanceof Set ? to : to !== undefined ? [to] : this.destinations;
22774
+ const targets = to instanceof Set
22775
+ ? to
22776
+ : to !== undefined
22777
+ ? [to]
22778
+ : __classPrivateFieldGet(this, _Result_routingState, "f").destinations;
22704
22779
  const expanded = new Set();
22705
22780
  for (const target of targets) {
22706
22781
  for (const equivalentStop of this.stopsIndex.equivalentStops(target)) {
@@ -22715,9 +22790,10 @@ class Result {
22715
22790
  * destination set)
22716
22791
  *
22717
22792
  * @param to The destination stop by SourceStopId.
22793
+ * @param maxTransfers Optional transfer limit within retained data.
22718
22794
  * @returns a route to the destination stop if it exists.
22719
22795
  */
22720
- bestRouteToSourceStopId(to) {
22796
+ bestRouteToSourceStopId(to, maxTransfers) {
22721
22797
  var _a;
22722
22798
  if (to instanceof Set) {
22723
22799
  const stopIds = new Set();
@@ -22726,10 +22802,14 @@ class Result {
22726
22802
  if (found !== undefined)
22727
22803
  stopIds.add(found.id);
22728
22804
  }
22729
- return stopIds.size === 0 ? undefined : this.bestRoute(stopIds);
22805
+ return stopIds.size === 0
22806
+ ? undefined
22807
+ : this.bestRoute(stopIds, maxTransfers);
22730
22808
  }
22731
22809
  const stopId = (_a = this.stopsIndex.findStopBySourceStopId(to)) === null || _a === void 0 ? void 0 : _a.id;
22732
- return stopId === undefined ? undefined : this.bestRoute(stopId);
22810
+ return stopId === undefined
22811
+ ? undefined
22812
+ : this.bestRoute(stopId, maxTransfers);
22733
22813
  }
22734
22814
  /**
22735
22815
  * Reconstructs the best route to a stop.
@@ -22738,9 +22818,10 @@ class Result {
22738
22818
  *
22739
22819
  * @param to The destination stop. Defaults to this result's resolved
22740
22820
  * destinations.
22821
+ * @param maxTransfers Optional transfer limit within retained data.
22741
22822
  * @returns a route to the destination stop if it exists.
22742
22823
  */
22743
- bestRoute(to) {
22824
+ bestRoute(to, maxTransfers) {
22744
22825
  var _a;
22745
22826
  const destinationStops = this.expandDestinations(to);
22746
22827
  // Find the fastest-reached destination across all equivalent stops.
@@ -22748,7 +22829,7 @@ class Result {
22748
22829
  let fastestArrivalTime = undefined;
22749
22830
  let fastestLegNumber = undefined;
22750
22831
  for (const destination of destinationStops) {
22751
- const arrivalData = this.routingState.getArrival(destination);
22832
+ const arrivalData = this.concreteArrivalAt(destination, maxTransfers);
22752
22833
  if (arrivalData !== undefined &&
22753
22834
  (fastestArrivalTime === undefined ||
22754
22835
  arrivalData.arrival < fastestArrivalTime)) {
@@ -22766,7 +22847,7 @@ class Result {
22766
22847
  let round = fastestLegNumber;
22767
22848
  let previousVehicleEdge;
22768
22849
  while (round >= 0) {
22769
- const edge = (_a = this.routingState.graph[round]) === null || _a === void 0 ? void 0 : _a[currentStop];
22850
+ const edge = (_a = __classPrivateFieldGet(this, _Result_routingState, "f").graph[round]) === null || _a === void 0 ? void 0 : _a[currentStop];
22770
22851
  if (!edge) {
22771
22852
  if (round === 0)
22772
22853
  break;
@@ -22928,34 +23009,14 @@ class Result {
22928
23009
  * than this result's destination set.
22929
23010
  *
22930
23011
  * @param stop The target stop for which to return the arrival time.
22931
- * @param maxTransfers The optional maximum number of transfers allowed.
23012
+ * @param maxTransfers Optional transfer limit within retained data.
22932
23013
  * @returns The arrival time if the target stop is reachable, otherwise undefined.
22933
23014
  */
22934
23015
  arrivalAt(stop, maxTransfers) {
22935
- var _a, _b;
22936
23016
  const equivalentStops = this.stopsIndex.equivalentStops(stop);
22937
23017
  let earliestArrival = undefined;
22938
23018
  for (const equivalentStop of equivalentStops) {
22939
- let arrivalTime;
22940
- if (maxTransfers === undefined ||
22941
- ((_a = this.routingState.getArrival(equivalentStop.id)) === null || _a === void 0 ? void 0 : _a.legNumber) ===
22942
- maxTransfers + 1) {
22943
- arrivalTime = this.routingState.getArrival(equivalentStop.id);
22944
- }
22945
- else {
22946
- // We have no guarantee that the stop was visited in the last round,
22947
- // so we need to check all rounds if it's not found in the last one.
22948
- for (let i = maxTransfers + 1; i >= 0; i--) {
22949
- const arrivalEdge = (_b = this.routingState.graph[i]) === null || _b === void 0 ? void 0 : _b[equivalentStop.id];
22950
- if (arrivalEdge !== undefined) {
22951
- arrivalTime = {
22952
- arrival: arrivalEdge.arrival,
22953
- legNumber: i,
22954
- };
22955
- break;
22956
- }
22957
- }
22958
- }
23019
+ const arrivalTime = this.concreteArrivalAt(equivalentStop.id, maxTransfers);
22959
23020
  if (arrivalTime !== undefined) {
22960
23021
  if (earliestArrival === undefined ||
22961
23022
  arrivalTime.arrival < earliestArrival.arrival) {
@@ -23366,7 +23427,7 @@ class PlainRouter {
23366
23427
  .map((destination) => destination.id);
23367
23428
  const routingState = new RoutingState(query.departureTime, destinations, accessLegs, this.timetable.nbStops(), query.options.maxTransfers + 1, query.options.maxDuration);
23368
23429
  this.raptor.run(query.options, routingState);
23369
- return new Result(new Set(destinations), routingState, this.stopsIndex, this.timetable);
23430
+ return new Result(routingState, this.stopsIndex, this.timetable);
23370
23431
  }
23371
23432
  }
23372
23433
 
@@ -23385,53 +23446,50 @@ class PlainRouter {
23385
23446
  * strictly earlier *and* arrives strictly earlier than the previous one,
23386
23447
  * forming the classic staircase Pareto frontier.
23387
23448
  *
23388
- * **Full-network mode** (empty `destinations`): when no destinations are
23449
+ * **Full-network mode** (no query destinations): when no destinations are
23389
23450
  * supplied to the range query every departure slot in the window becomes its
23390
23451
  * own run, because destination-based Pareto pruning cannot be applied.
23391
- * In this mode the destination-specific helpers ({@link getRoutes},
23452
+ * In this mode the destination-specific helpers ({@link routes},
23392
23453
  * {@link bestRoute}, {@link latestDepartureRoute}, {@link fastestRoute})
23393
- * return empty results; use {@link allEarliestArrivals},
23394
- * {@link allShortestDurations}, {@link earliestArrivalAt}, or
23454
+ * return empty results; use {@link arrivals},
23455
+ * {@link shortestDurations}, {@link arrivalAt}, or
23395
23456
  * {@link shortestDurationTo} instead.
23396
23457
  *
23397
23458
  * Destination handling is delegated to {@link Result}, which expands
23398
23459
  * equivalent stops when reconstructing routes or looking up arrivals.
23399
23460
  */
23400
23461
  class RangeResult {
23401
- constructor(runs, destinations) {
23462
+ constructor(runs) {
23402
23463
  this._runs = runs;
23403
- this._destinations = destinations;
23404
- }
23405
- /** The resolved destination stop IDs for this result. */
23406
- get destinations() {
23407
- return this._destinations;
23408
23464
  }
23409
23465
  normalizeTargets(to) {
23466
+ var _a;
23410
23467
  if (to instanceof Set)
23411
23468
  return new Set(to);
23412
23469
  if (to !== undefined)
23413
23470
  return new Set([to]);
23414
- return new Set(this._destinations);
23471
+ return new Set((_a = this._runs[0]) === null || _a === void 0 ? void 0 : _a.result[resultDestinations]());
23415
23472
  }
23416
23473
  /**
23417
- * Returns all non-dominated routes to this result's default destination set,
23474
+ * Lazily yields all non-dominated routes to this result's default destination set,
23418
23475
  * ordered from the earliest departure to the latest departure.
23419
23476
  *
23420
- * Each route in the list departs strictly earlier *and* arrives strictly
23421
- * earlier than its predecessor.
23477
+ * Each route in the list departs strictly later *and* arrives strictly
23478
+ * later than its predecessor.
23422
23479
  *
23423
- * Returns an empty array when no destinations were provided (full-network
23424
- * mode). Use {@link allEarliestArrivals} or {@link allShortestDurations}
23480
+ * Yields nothing when no destinations were provided (full-network
23481
+ * mode). Use {@link arrivals} or {@link shortestDurations}
23425
23482
  * to query individual stops in that case.
23426
23483
  */
23427
- getRoutes() {
23428
- const routes = [];
23429
- for (const { result } of this._runs) {
23430
- const route = result.bestRoute();
23484
+ *routes() {
23485
+ for (let index = this._runs.length - 1; index >= 0; index--) {
23486
+ const run = this._runs[index];
23487
+ if (run === undefined)
23488
+ continue;
23489
+ const route = run.result.bestRoute();
23431
23490
  if (route !== undefined)
23432
- routes.push(route);
23491
+ yield route;
23433
23492
  }
23434
- return routes.reverse();
23435
23493
  }
23436
23494
  /**
23437
23495
  * The route that arrives **earliest** at the given stop(s) across all
@@ -23446,16 +23504,17 @@ class RangeResult {
23446
23504
  * (no destinations), otherwise `undefined` is returned.
23447
23505
  *
23448
23506
  * @param to Optional destination stop ID or set of stop IDs.
23507
+ * @param maxTransfers Optional transfer limit within retained data.
23449
23508
  * @returns The reconstructed {@link Route} with the earliest arrival,
23450
23509
  * or `undefined` if the target is unreachable in every run.
23451
23510
  */
23452
- bestRoute(to) {
23511
+ bestRoute(to, maxTransfers) {
23453
23512
  const targetStops = this.normalizeTargets(to);
23454
23513
  let bestRun;
23455
23514
  let bestArrival;
23456
23515
  for (const run of this._runs) {
23457
23516
  for (const stopId of targetStops) {
23458
- const arrival = run.result.arrivalAt(stopId);
23517
+ const arrival = run.result.arrivalAt(stopId, maxTransfers);
23459
23518
  if (arrival === undefined)
23460
23519
  continue;
23461
23520
  if (bestArrival === undefined || arrival.arrival < bestArrival) {
@@ -23464,7 +23523,7 @@ class RangeResult {
23464
23523
  }
23465
23524
  }
23466
23525
  }
23467
- return bestRun === null || bestRun === void 0 ? void 0 : bestRun.result.bestRoute(targetStops);
23526
+ return bestRun === null || bestRun === void 0 ? void 0 : bestRun.result.bestRoute(targetStops, maxTransfers);
23468
23527
  }
23469
23528
  /**
23470
23529
  * The route with the **latest possible departure** from the origin among all
@@ -23480,13 +23539,14 @@ class RangeResult {
23480
23539
  * (no destinations), otherwise `undefined` is returned.
23481
23540
  *
23482
23541
  * @param to Optional destination stop ID or set of stop IDs.
23542
+ * @param maxTransfers Optional transfer limit within retained data.
23483
23543
  * @returns The reconstructed {@link Route} with the latest departure,
23484
23544
  * or `undefined` if the target is unreachable in every run.
23485
23545
  */
23486
- latestDepartureRoute(to) {
23546
+ latestDepartureRoute(to, maxTransfers) {
23487
23547
  const targetStops = this.normalizeTargets(to);
23488
23548
  for (const { result } of this._runs) {
23489
- const route = result.bestRoute(targetStops);
23549
+ const route = result.bestRoute(targetStops, maxTransfers);
23490
23550
  if (route !== undefined)
23491
23551
  return route;
23492
23552
  }
@@ -23506,16 +23566,17 @@ class RangeResult {
23506
23566
  * (no destinations), otherwise `undefined` is returned.
23507
23567
  *
23508
23568
  * @param to Optional destination stop ID or set of stop IDs.
23569
+ * @param maxTransfers Optional transfer limit within retained data.
23509
23570
  * @returns The reconstructed fastest {@link Route}, or `undefined` if the
23510
23571
  * target is unreachable in every run.
23511
23572
  */
23512
- fastestRoute(to) {
23573
+ fastestRoute(to, maxTransfers) {
23513
23574
  const targetStops = this.normalizeTargets(to);
23514
23575
  let fastestRun;
23515
23576
  let shortestDuration = Infinity;
23516
23577
  for (const run of this._runs) {
23517
23578
  for (const stopId of targetStops) {
23518
- const arrival = run.result.arrivalAt(stopId);
23579
+ const arrival = run.result.arrivalAt(stopId, maxTransfers);
23519
23580
  if (arrival === undefined)
23520
23581
  continue;
23521
23582
  const duration = arrival.arrival - run.departureTime;
@@ -23528,7 +23589,7 @@ class RangeResult {
23528
23589
  }
23529
23590
  }
23530
23591
  }
23531
- return fastestRun === null || fastestRun === void 0 ? void 0 : fastestRun.result.bestRoute(targetStops);
23592
+ return fastestRun === null || fastestRun === void 0 ? void 0 : fastestRun.result.bestRoute(targetStops, maxTransfers);
23532
23593
  }
23533
23594
  /** Number of Pareto-optimal journeys found. */
23534
23595
  get size() {
@@ -23544,9 +23605,9 @@ class RangeResult {
23544
23605
  * Equivalent stops are handled by {@link Result.arrivalAt}.
23545
23606
  *
23546
23607
  * @param stop The target stop ID.
23547
- * @param maxTransfers Optional upper bound on the number of transfers.
23608
+ * @param maxTransfers Optional transfer limit within retained data.
23548
23609
  */
23549
- earliestArrivalAt(stop, maxTransfers) {
23610
+ arrivalAt(stop, maxTransfers) {
23550
23611
  let best;
23551
23612
  for (const { result } of this._runs) {
23552
23613
  const arrival = result.arrivalAt(stop, maxTransfers);
@@ -23573,7 +23634,7 @@ class RangeResult {
23573
23634
  * Returns `undefined` if `stop` is unreachable in every run.
23574
23635
  *
23575
23636
  * @param stop The target stop ID.
23576
- * @param maxTransfers Optional upper bound on the number of transfers.
23637
+ * @param maxTransfers Optional transfer limit within retained data.
23577
23638
  */
23578
23639
  shortestDurationTo(stop, maxTransfers) {
23579
23640
  let shortest;
@@ -23590,12 +23651,15 @@ class RangeResult {
23590
23651
  }
23591
23652
  /**
23592
23653
  * Shortest travel duration to **every reachable stop** across all
23593
- * Pareto-optimal runs, as a single `Map<StopId, DurationArrival>`.
23654
+ * Pareto-optimal runs, yielding the stop ID and arrival with duration.
23655
+ * All runs are aggregated before the first value is yielded. Ties retain
23656
+ * the first run's arrival and leg count.
23657
+ * @param maxTransfers Optional transfer limit within retained data.
23594
23658
  */
23595
- allShortestDurations() {
23659
+ *shortestDurations(maxTransfers) {
23596
23660
  const durations = new Map();
23597
23661
  for (const { departureTime, result } of this._runs) {
23598
- for (const { stop, arrival, legNumber, } of result.routingState.arrivals()) {
23662
+ for (const { stop, arrival, legNumber } of result.arrivals(maxTransfers)) {
23599
23663
  const duration = arrival - departureTime;
23600
23664
  const existing = durations.get(stop);
23601
23665
  if (existing === undefined || duration < existing.duration) {
@@ -23603,23 +23667,30 @@ class RangeResult {
23603
23667
  }
23604
23668
  }
23605
23669
  }
23606
- return durations;
23670
+ for (const [stop, arrival] of durations) {
23671
+ yield Object.assign({ stop }, arrival);
23672
+ }
23607
23673
  }
23608
23674
  /**
23609
23675
  * Earliest achievable arrival at **every reachable stop** across all
23610
- * Pareto-optimal runs, as a single `Map<StopId, Arrival>`.
23676
+ * Pareto-optimal runs, yielding the stop ID and arrival.
23677
+ * All runs are aggregated before the first value is yielded. Ties retain
23678
+ * the first run's arrival and leg count.
23679
+ * @param maxTransfers Optional transfer limit within retained data.
23611
23680
  */
23612
- allEarliestArrivals() {
23681
+ *arrivals(maxTransfers) {
23613
23682
  const arrivals = new Map();
23614
23683
  for (const { result } of this._runs) {
23615
- for (const { stop, arrival, legNumber, } of result.routingState.arrivals()) {
23684
+ for (const { stop, arrival, legNumber } of result.arrivals(maxTransfers)) {
23616
23685
  const existing = arrivals.get(stop);
23617
23686
  if (existing === undefined || arrival < existing.arrival) {
23618
23687
  arrivals.set(stop, { arrival, legNumber });
23619
23688
  }
23620
23689
  }
23621
23690
  }
23622
- return arrivals;
23691
+ for (const [stop, arrival] of arrivals) {
23692
+ yield Object.assign({ stop }, arrival);
23693
+ }
23623
23694
  }
23624
23695
  /**
23625
23696
  * Iterates over all Pareto-optimal `(departureTime, result)` pairs,
@@ -23771,7 +23842,7 @@ class RangeRouter {
23771
23842
  const accessLegs = this.accessFinder.collectAccessPaths(query.from, query.options.minTransferTime);
23772
23843
  const departureSlots = this.accessFinder.collectDepartureTimes(accessLegs, earliest, latest);
23773
23844
  if (departureSlots.length === 0) {
23774
- return new RangeResult([], new Set(destinations));
23845
+ return new RangeResult([]);
23775
23846
  }
23776
23847
  const maxRounds = query.options.maxTransfers + 1;
23777
23848
  const rangeState = new RangeRaptorState(maxRounds, this.timetable.nbStops(), latest);
@@ -23830,12 +23901,12 @@ class RangeRouter {
23830
23901
  if (isParetoOptimal) {
23831
23902
  paretoRuns.push({
23832
23903
  departureTime: depTime,
23833
- result: new Result(new Set(destinations), routingState, this.stopsIndex, this.timetable),
23904
+ result: new Result(routingState, this.stopsIndex, this.timetable),
23834
23905
  });
23835
23906
  routingState = null;
23836
23907
  }
23837
23908
  }
23838
- return new RangeResult(paretoRuns, new Set(destinations));
23909
+ return new RangeResult(paretoRuns);
23839
23910
  }
23840
23911
  }
23841
23912
 
@@ -24338,24 +24409,24 @@ const testRangeRouterPerformance = (router, tasks, iterations, stopsIndex) => {
24338
24409
  return results;
24339
24410
  };
24340
24411
  /**
24341
- * Benchmarks {@link RangeResult.getRoutes} — the full Pareto-frontier
24412
+ * Benchmarks {@link RangeResult.routes} — the full Pareto-frontier
24342
24413
  * reconstruction phase — independently of the range routing phase.
24343
24414
  *
24344
24415
  * @param router - The router instance used to produce the range results that
24345
- * are then fed into `getRoutes`.
24416
+ * are then fed into `routes`.
24346
24417
  * @param tasks - The list of range queries to benchmark. One
24347
24418
  * {@link PerformanceResult} is produced per query.
24348
- * @param iterations - Number of times `getRoutes` is called per query.
24419
+ * @param iterations - Number of times `routes` is fully consumed per query.
24349
24420
  * @param stopsIndex - Used to resolve stop names for result labels.
24350
24421
  * @returns An array of {@link PerformanceResult} objects, one per query, each
24351
24422
  * containing the mean wall-clock time (µs) and mean heap and ArrayBuffer deltas (MiB) for the
24352
- * `getRoutes` call alone.
24423
+ * full `routes` iteration alone.
24353
24424
  */
24354
24425
  const testRangeResultPerformance = (router, tasks, iterations, stopsIndex) => {
24355
24426
  const results = [];
24356
24427
  for (const task of tasks) {
24357
24428
  const rangeResult = router.rangeRoute(task);
24358
- results.push(Object.assign({ label: buildQueryLabel(task, stopsIndex) }, measurePerformance(() => rangeResult.getRoutes(), iterations)));
24429
+ results.push(Object.assign({ label: buildQueryLabel(task, stopsIndex) }, measurePerformance(() => [...rangeResult.routes()], iterations)));
24359
24430
  }
24360
24431
  return results;
24361
24432
  };
@@ -24556,7 +24627,7 @@ const startRepl = (stopsPath, timetablePath) => {
24556
24627
  console.log(`Found ${result.size} Pareto-optimal journey${result.size === 1 ? '' : 's'} ` +
24557
24628
  `from ${fromStop.name} to ${toStop.name} ` +
24558
24629
  `(window ${atTime}–${beforeTime}):`);
24559
- const routes = result.getRoutes();
24630
+ const routes = [...result.routes()];
24560
24631
  routes.forEach((route, index) => {
24561
24632
  const journeyNumber = index + 1;
24562
24633
  console.log(`\nJourney ${journeyNumber}:`);
@@ -24978,7 +25049,7 @@ program
24978
25049
  const rangeRouterResults = testRangeRouterPerformance(router, rangeQueries, iterations, stopsIndex);
24979
25050
  prettyPrintPerformanceResults(rangeRouterResults, 'Range queries — router.rangeRoute()');
24980
25051
  const rangeResultResults = testRangeResultPerformance(router, rangeQueries, iterations, stopsIndex);
24981
- prettyPrintPerformanceResults(rangeResultResults, 'Range queries — rangeResult.getRoutes() (reconstruction only)');
25052
+ prettyPrintPerformanceResults(rangeResultResults, 'Range queries — rangeResult.routes() (reconstruction only)');
24982
25053
  });
24983
25054
  program.parse(process.argv);
24984
25055
  //# sourceMappingURL=cli.mjs.map