(timetable)
| 27 | } |
| 28 | |
| 29 | add(timetable) { |
| 30 | const {array, trainLookup, railwayDirectionLookup} = this, |
| 31 | trainId = timetable.t, |
| 32 | timetablesByTrain = trainLookup.get(trainId), |
| 33 | railwayDirectionId = `${timetable.r.id}:${timetable.d.id}`, |
| 34 | timetablesByDirection = railwayDirectionLookup.get(railwayDirectionId); |
| 35 | |
| 36 | array.push(timetable); |
| 37 | |
| 38 | if (Array.isArray(timetablesByTrain)) { |
| 39 | timetablesByTrain.push(timetable); |
| 40 | } else { |
| 41 | trainLookup.set(trainId, timetablesByTrain ? [timetablesByTrain, timetable] : timetable); |
| 42 | } |
| 43 | |
| 44 | if (timetablesByDirection) { |
| 45 | timetablesByDirection.push(timetable); |
| 46 | } else { |
| 47 | railwayDirectionLookup.set(railwayDirectionId, [timetable]); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | getByTrainId(trainId) { |
| 52 | const timetables = this.trainLookup.get(trainId); |
no test coverage detected