@transportme/load-ptv-gtfs 1.4.19 → 1.4.20
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.
|
@@ -201,6 +201,7 @@ export default class TripLoader {
|
|
|
201
201
|
this.updateStopServices(processedData)
|
|
202
202
|
|
|
203
203
|
this.#tripsToLoad.push(processedData)
|
|
204
|
+
this.#tripDetails[tripID] = null // Clear it from the cache once loaded to free up some memory
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
updateStopServices(trip) {
|
|
@@ -226,7 +227,7 @@ export default class TripLoader {
|
|
|
226
227
|
* @param {object} options.routeIDMap A mapping of full route IDs to their simplified IDs.
|
|
227
228
|
* @param {function} [options.processTrip] A function to modify trip data on a per-trip basis. It should return null to discard the trip.
|
|
228
229
|
*/
|
|
229
|
-
async loadTrips({ routeIDMap, processTrip }) {
|
|
230
|
+
async loadTrips({ routeIDMap, processTrip, onWrite = () => {} }) {
|
|
230
231
|
this.#routeIDMap = routeIDMap
|
|
231
232
|
|
|
232
233
|
await this.loadCalendarData()
|
|
@@ -242,11 +243,13 @@ export default class TripLoader {
|
|
|
242
243
|
if (this.#tripsToLoad.length === 5000) { // Flush the cache every 5000 trips
|
|
243
244
|
tripsLoaded += this.#tripsToLoad.length
|
|
244
245
|
await this.writeTrips()
|
|
246
|
+
onWrite(tripsLoaded)
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
tripsLoaded += this.#tripsToLoad.length
|
|
249
251
|
await this.writeTrips()
|
|
252
|
+
onWrite(tripsLoaded)
|
|
250
253
|
}
|
|
251
254
|
|
|
252
255
|
getTripsToLoad() {
|