bus-mj 2.2.4 → 2.2.6
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/data/relations.js +2 -2
- package/package.json +1 -1
- package/src/getBus.js +30 -7
package/data/relations.js
CHANGED
|
@@ -477,7 +477,7 @@ export default [
|
|
|
477
477
|
tags: {
|
|
478
478
|
color: "orange",
|
|
479
479
|
band: ["blue", "red"],
|
|
480
|
-
board: "
|
|
480
|
+
board: "blue",
|
|
481
481
|
fee: "yes",
|
|
482
482
|
from: "Belobaka",
|
|
483
483
|
name: "Ligne 7 Plaque Manga",
|
|
@@ -964,7 +964,7 @@ export default [
|
|
|
964
964
|
tags: {
|
|
965
965
|
color: "orange",
|
|
966
966
|
band: ["blue", "red"],
|
|
967
|
-
board: "
|
|
967
|
+
board: "red",
|
|
968
968
|
fee: "yes",
|
|
969
969
|
from: "Belobaka",
|
|
970
970
|
name: "Ligne 7 Plaque Mena",
|
package/package.json
CHANGED
package/src/getBus.js
CHANGED
|
@@ -66,7 +66,10 @@ export function findBusByOneStop(stop_id) {
|
|
|
66
66
|
*/
|
|
67
67
|
export function findBusByStopLabel(stop_label) {
|
|
68
68
|
return relations.filter((relation) => {
|
|
69
|
-
return relation.members.some(
|
|
69
|
+
return relation.members.some(
|
|
70
|
+
(member) =>
|
|
71
|
+
member.label && member.label.toUpperCase() == stop_label.toUpperCase()
|
|
72
|
+
);
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -76,10 +79,30 @@ export function findBusByStopLabel(stop_label) {
|
|
|
76
79
|
* @param {Bus[]} __relation list of bus to filter
|
|
77
80
|
* @returns { Bus[] }
|
|
78
81
|
*/
|
|
79
|
-
export function __findBusByStopLabel(stop_label,
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
export function __findBusByStopLabel(stop_label, relations, beginLabel) {
|
|
83
|
+
return relations
|
|
84
|
+
.map((rel) => {
|
|
85
|
+
const beginIndex = rel.members.findIndex(
|
|
86
|
+
(m) => m.label?.toUpperCase() === beginLabel.toUpperCase()
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const endIndex = rel.members.findIndex(
|
|
90
|
+
(m) => m.label?.toUpperCase() === stop_label.toUpperCase()
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
if (beginIndex === -1 || endIndex === -1) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const start = Math.min(beginIndex, endIndex);
|
|
98
|
+
const end = Math.max(beginIndex, endIndex);
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
...rel,
|
|
102
|
+
members: rel.members.slice(start, end + 1),
|
|
103
|
+
};
|
|
104
|
+
})
|
|
105
|
+
.filter(Boolean);
|
|
83
106
|
}
|
|
84
107
|
|
|
85
108
|
/**
|
|
@@ -103,7 +126,7 @@ export function findBusByTwoStop(begin, end) {
|
|
|
103
126
|
*/
|
|
104
127
|
export function findBusByTwoStopLabel(begin, end) {
|
|
105
128
|
let firstRelationsFound = findBusByStopLabel(begin);
|
|
106
|
-
return __findBusByStopLabel(end, firstRelationsFound);
|
|
129
|
+
return __findBusByStopLabel(end, firstRelationsFound, begin);
|
|
107
130
|
}
|
|
108
131
|
|
|
109
132
|
/**
|
|
@@ -159,4 +182,4 @@ export function findZoneAll() {
|
|
|
159
182
|
(value, index, self) =>
|
|
160
183
|
self.indexOf(value) === index && value != undefined
|
|
161
184
|
);
|
|
162
|
-
}
|
|
185
|
+
}
|