bus-mj 2.2.6 → 2.2.8
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/index.d.ts +2 -1
- package/index.js +4 -2
- package/package.json +1 -1
- package/src/getBus.js +11 -6
package/index.d.ts
CHANGED
|
@@ -39,4 +39,5 @@ export function findBusDetailByOperator(operatorName: string): Bus[];
|
|
|
39
39
|
export function findOpenHoursAll(): string[];
|
|
40
40
|
export function findStopByRef(ref: number): Stop;
|
|
41
41
|
export function findBusByStopLabel(label: string): Bus[];
|
|
42
|
-
export function findBusByTwoStopLabel(begin: string, end: string): Bus[];
|
|
42
|
+
export function findBusByTwoStopLabel(begin: string, end: string): Bus[];
|
|
43
|
+
export function findBusOperator(operator: string): Bus[];
|
package/index.js
CHANGED
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
findOpenHoursAll,
|
|
11
11
|
findStopByRef,
|
|
12
12
|
findBusByStopLabel,
|
|
13
|
-
findBusByTwoStopLabel
|
|
13
|
+
findBusByTwoStopLabel,
|
|
14
|
+
findBusOperator
|
|
14
15
|
} from "./src/getBus.js";
|
|
15
16
|
|
|
16
17
|
export {
|
|
@@ -25,5 +26,6 @@ export {
|
|
|
25
26
|
findOpenHoursAll,
|
|
26
27
|
findStopByRef,
|
|
27
28
|
findBusByStopLabel,
|
|
28
|
-
findBusByTwoStopLabel
|
|
29
|
+
findBusByTwoStopLabel,
|
|
30
|
+
findBusOperator
|
|
29
31
|
};
|
package/package.json
CHANGED
package/src/getBus.js
CHANGED
|
@@ -86,7 +86,7 @@ export function __findBusByStopLabel(stop_label, relations, beginLabel) {
|
|
|
86
86
|
(m) => m.label?.toUpperCase() === beginLabel.toUpperCase()
|
|
87
87
|
);
|
|
88
88
|
|
|
89
|
-
const endIndex = rel.members.
|
|
89
|
+
const endIndex = rel.members.findLastIndex(
|
|
90
90
|
(m) => m.label?.toUpperCase() === stop_label.toUpperCase()
|
|
91
91
|
);
|
|
92
92
|
|
|
@@ -94,15 +94,12 @@ export function __findBusByStopLabel(stop_label, relations, beginLabel) {
|
|
|
94
94
|
return null;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
const start = Math.min(beginIndex, endIndex);
|
|
98
|
-
const end = Math.max(beginIndex, endIndex);
|
|
99
|
-
|
|
100
97
|
return {
|
|
101
98
|
...rel,
|
|
102
|
-
members: rel.members.slice(
|
|
99
|
+
members: rel.members.slice(beginIndex, endIndex + 1),
|
|
103
100
|
};
|
|
104
101
|
})
|
|
105
|
-
.filter(
|
|
102
|
+
.filter((bus) => bus !== null && bus.members.length > 0);
|
|
106
103
|
}
|
|
107
104
|
|
|
108
105
|
/**
|
|
@@ -150,6 +147,14 @@ export function findBusAll() {
|
|
|
150
147
|
return relations;
|
|
151
148
|
}
|
|
152
149
|
|
|
150
|
+
/**
|
|
151
|
+
* fetch bus by operator
|
|
152
|
+
* @returns { Bus[] }
|
|
153
|
+
*/
|
|
154
|
+
export function findBusOperator(operator) {
|
|
155
|
+
return relations.filter((e) => e.tags.operator == operator);
|
|
156
|
+
}
|
|
157
|
+
|
|
153
158
|
/**
|
|
154
159
|
* fetch all operator
|
|
155
160
|
* @returns { string[] }
|