bus-mj 2.2.0 → 2.2.2
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 +6 -3
- package/index.js +12 -6
- package/package.json +1 -1
- package/src/getBus.js +13 -2
package/index.d.ts
CHANGED
|
@@ -28,12 +28,15 @@ type Stop = {
|
|
|
28
28
|
label: string | null,
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
export function findBusAll(): Bus[];
|
|
31
32
|
export function findStopAll(): Stop[];
|
|
33
|
+
export function findBusDetailById(busId: number): Bus;
|
|
32
34
|
export function findBusByOneStop(stopId: number): Bus[];
|
|
33
35
|
export function findBusByTwoStop(startStopId: number, endStopId: number): Bus[];
|
|
34
|
-
export function findBusDetailById(busId: number): Bus;
|
|
35
|
-
export function findBusAll(): Bus[];
|
|
36
36
|
export function findOperatorAll(): string[];
|
|
37
37
|
export function findZoneAll(): string[];
|
|
38
38
|
export function findBusDetailByOperator(operatorName: string): Bus[];
|
|
39
|
-
export function findOpenHoursAll(): string[];
|
|
39
|
+
export function findOpenHoursAll(): string[];
|
|
40
|
+
export function findStopByRef(ref: number): Stop;
|
|
41
|
+
export function findBusByStopLabel(label: string): Bus[];
|
|
42
|
+
export function findBusByTwoStopLabel(begin: string, end: string): Bus[];
|
package/index.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
+
findBusAll,
|
|
2
3
|
findStopAll,
|
|
4
|
+
findBusDetailById,
|
|
3
5
|
findBusByOneStop,
|
|
4
6
|
findBusByTwoStop,
|
|
5
|
-
findBusDetailById,
|
|
6
|
-
findBusAll,
|
|
7
7
|
findOperatorAll,
|
|
8
8
|
findZoneAll,
|
|
9
9
|
findBusDetailByOperator,
|
|
10
|
-
findOpenHoursAll
|
|
10
|
+
findOpenHoursAll,
|
|
11
|
+
findStopByRef,
|
|
12
|
+
findBusByStopLabel,
|
|
13
|
+
findBusByTwoStopLabel
|
|
11
14
|
} from "./src/getBus.js";
|
|
12
15
|
|
|
13
16
|
export {
|
|
17
|
+
findBusAll,
|
|
14
18
|
findStopAll,
|
|
19
|
+
findBusDetailById,
|
|
15
20
|
findBusByOneStop,
|
|
16
21
|
findBusByTwoStop,
|
|
17
|
-
findBusDetailById,
|
|
18
|
-
findBusAll,
|
|
19
22
|
findOperatorAll,
|
|
20
23
|
findZoneAll,
|
|
21
24
|
findBusDetailByOperator,
|
|
22
|
-
findOpenHoursAll
|
|
25
|
+
findOpenHoursAll,
|
|
26
|
+
findStopByRef,
|
|
27
|
+
findBusByStopLabel,
|
|
28
|
+
findBusByTwoStopLabel
|
|
23
29
|
};
|
package/package.json
CHANGED
package/src/getBus.js
CHANGED
|
@@ -25,7 +25,18 @@ export function findStopByRef(ref) {
|
|
|
25
25
|
* @returns { Stop[] }
|
|
26
26
|
*/
|
|
27
27
|
export function findStopAll() {
|
|
28
|
-
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
|
|
30
|
+
return nodes.filter((node) => {
|
|
31
|
+
if (!node.label) return false;
|
|
32
|
+
|
|
33
|
+
if (seen.has(node.label)) {
|
|
34
|
+
return false; // already see → pass
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
seen.add(node.label);
|
|
38
|
+
return true; // first found → keep
|
|
39
|
+
});
|
|
29
40
|
}
|
|
30
41
|
|
|
31
42
|
/**
|
|
@@ -50,7 +61,7 @@ export function findBusByOneStop(stop_id) {
|
|
|
50
61
|
|
|
51
62
|
/**
|
|
52
63
|
* find Bus that have a one stop asked
|
|
53
|
-
* @param {
|
|
64
|
+
* @param {string} stop_label label of stop
|
|
54
65
|
* @returns { Bus[] }
|
|
55
66
|
*/
|
|
56
67
|
export function findBusByStopLabel(stop_label) {
|