bus-mj 2.0.0 → 2.1.0
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/nodes.js +1 -1
- package/data/relations.js +1 -1
- package/data/result.json +22531 -0
- package/index.d.ts +9 -11
- package/index.js +4 -4
- package/package.json +17 -3
- package/src/getBus.js +17 -26
- package/tsconfig.json +0 -0
package/index.d.ts
CHANGED
|
@@ -28,14 +28,12 @@ type Stop = {
|
|
|
28
28
|
label: string | null,
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export function findOpenHoursAll(): string[];
|
|
41
|
-
}
|
|
31
|
+
export function findStopAll(): Stop[];
|
|
32
|
+
export function findBusByOneStop(stopId: number): Bus[];
|
|
33
|
+
export function findBusByTwoStop(startStopId: number, endStopId: number): Bus[];
|
|
34
|
+
export function findBusDetailById(busId: number): Bus;
|
|
35
|
+
export function findBusAll(): Bus[];
|
|
36
|
+
export function findOperatorAll(): string[];
|
|
37
|
+
export function findZoneAll(): string[];
|
|
38
|
+
export function findBusDetailByOperator(operatorName: string): Bus[];
|
|
39
|
+
export function findOpenHoursAll(): string[];
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
findStopAll,
|
|
3
3
|
findBusByOneStop,
|
|
4
4
|
findBusByTwoStop,
|
|
@@ -8,9 +8,9 @@ const {
|
|
|
8
8
|
findZoneAll,
|
|
9
9
|
findBusDetailByOperator,
|
|
10
10
|
findOpenHoursAll
|
|
11
|
-
}
|
|
11
|
+
} from "./src/getBus.js";
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export {
|
|
14
14
|
findStopAll,
|
|
15
15
|
findBusByOneStop,
|
|
16
16
|
findBusByTwoStop,
|
|
@@ -20,4 +20,4 @@ module.exports = {
|
|
|
20
20
|
findZoneAll,
|
|
21
21
|
findBusDetailByOperator,
|
|
22
22
|
findOpenHoursAll
|
|
23
|
-
};
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bus-mj",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "package for BUS station in Mahajanga",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "index.js",
|
|
6
|
-
"
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"import": "./index.js",
|
|
12
|
+
"default": "./index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"scripts": {
|
|
8
|
-
"test": "
|
|
16
|
+
"test": "node -e \"const {findBusAll, findStopAll} = require('./index.js'); console.log('✓ Module loaded successfully'); console.log('✓ Buses found:', findBusAll().length); console.log('✓ Stops found:', findStopAll().length);\""
|
|
9
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"index.js",
|
|
20
|
+
"index.d.ts",
|
|
21
|
+
"src/",
|
|
22
|
+
"data/"
|
|
23
|
+
],
|
|
10
24
|
"repository": {
|
|
11
25
|
"type": "git",
|
|
12
26
|
"url": "git+https://github.com/selestinohajaniaina/bus-mahajanga-api.git"
|
package/src/getBus.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/getBus.js
|
|
2
|
+
import relationsData from "../data/relations.js";
|
|
3
|
+
import nodesData from "../data/nodes.js";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
const nodes = nodesData;
|
|
6
|
+
|
|
7
|
+
let relations = relationsData.map((relation) => {
|
|
5
8
|
relation.members = relation.members.map((member) =>
|
|
6
9
|
findStopByRef(member.ref)
|
|
7
10
|
);
|
|
@@ -13,7 +16,7 @@ relations = relations.map((relation) => {
|
|
|
13
16
|
* @param {number} ref id of node
|
|
14
17
|
* @returns { Stop } detail of bus'stop
|
|
15
18
|
*/
|
|
16
|
-
function findStopByRef(ref) {
|
|
19
|
+
export function findStopByRef(ref) {
|
|
17
20
|
return nodes.find((e) => e.id === ref);
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -21,7 +24,7 @@ function findStopByRef(ref) {
|
|
|
21
24
|
* list all STOPS in data
|
|
22
25
|
* @returns { Stop[] }
|
|
23
26
|
*/
|
|
24
|
-
function findStopAll() {
|
|
27
|
+
export function findStopAll() {
|
|
25
28
|
return nodes.filter((node) => node.label != undefined);
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -30,7 +33,7 @@ function findStopAll() {
|
|
|
30
33
|
* @param {number} bus_id id of bus ...
|
|
31
34
|
* @returns { Bus }
|
|
32
35
|
*/
|
|
33
|
-
function findBusDetailById(bus_id) {
|
|
36
|
+
export function findBusDetailById(bus_id) {
|
|
34
37
|
return relations.find((bus) => bus.id == bus_id);
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -39,7 +42,7 @@ function findBusDetailById(bus_id) {
|
|
|
39
42
|
* @param {number} stop_id id of stop
|
|
40
43
|
* @returns { Bus[] }
|
|
41
44
|
*/
|
|
42
|
-
function findBusByOneStop(stop_id) {
|
|
45
|
+
export function findBusByOneStop(stop_id) {
|
|
43
46
|
return relations.filter((relation) => {
|
|
44
47
|
return relation.members.some((member) => member.ref === stop_id);
|
|
45
48
|
});
|
|
@@ -51,7 +54,7 @@ function findBusByOneStop(stop_id) {
|
|
|
51
54
|
* @param {number} end STOP_ID - end of Road
|
|
52
55
|
* @returns { Bus[] }
|
|
53
56
|
*/
|
|
54
|
-
function findBusByTwoStop(begin, end) {
|
|
57
|
+
export function findBusByTwoStop(begin, end) {
|
|
55
58
|
let firstRelationsFound = findBusByOneStop(begin);
|
|
56
59
|
return firstRelationsFound.filter((relation) => {
|
|
57
60
|
return relation.members.some((member) => member.ref === end);
|
|
@@ -63,7 +66,7 @@ function findBusByTwoStop(begin, end) {
|
|
|
63
66
|
* @param {string} operator_name id of operator ...
|
|
64
67
|
* @returns { Bus[] }
|
|
65
68
|
*/
|
|
66
|
-
function findBusDetailByOperator(operator_name) {
|
|
69
|
+
export function findBusDetailByOperator(operator_name) {
|
|
67
70
|
return relations.filter(
|
|
68
71
|
(bus) =>
|
|
69
72
|
bus.tags.operator &&
|
|
@@ -75,7 +78,7 @@ function findBusDetailByOperator(operator_name) {
|
|
|
75
78
|
* fetch all bus
|
|
76
79
|
* @returns { Bus[] }
|
|
77
80
|
*/
|
|
78
|
-
function findBusAll() {
|
|
81
|
+
export function findBusAll() {
|
|
79
82
|
return relations;
|
|
80
83
|
}
|
|
81
84
|
|
|
@@ -83,7 +86,7 @@ function findBusAll() {
|
|
|
83
86
|
* fetch all operator
|
|
84
87
|
* @returns { string[] }
|
|
85
88
|
*/
|
|
86
|
-
function findOperatorAll() {
|
|
89
|
+
export function findOperatorAll() {
|
|
87
90
|
return relations
|
|
88
91
|
.map((relation) => relation.tags.operator)
|
|
89
92
|
.filter(
|
|
@@ -96,7 +99,7 @@ function findOperatorAll() {
|
|
|
96
99
|
* fetch all opennning hours
|
|
97
100
|
* @returns { string[] }
|
|
98
101
|
*/
|
|
99
|
-
function findOpenHoursAll() {
|
|
102
|
+
export function findOpenHoursAll() {
|
|
100
103
|
return relations.map((relation) => relation.tags.opening_hours);
|
|
101
104
|
}
|
|
102
105
|
|
|
@@ -104,23 +107,11 @@ function findOpenHoursAll() {
|
|
|
104
107
|
* fetch all zone
|
|
105
108
|
* @returns { string[] }
|
|
106
109
|
*/
|
|
107
|
-
function findZoneAll() {
|
|
110
|
+
export function findZoneAll() {
|
|
108
111
|
return relations
|
|
109
112
|
.map((relation) => relation.tags.network)
|
|
110
113
|
.filter(
|
|
111
114
|
(value, index, self) =>
|
|
112
115
|
self.indexOf(value) === index && value != undefined
|
|
113
116
|
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
module.exports = {
|
|
117
|
-
findStopAll,
|
|
118
|
-
findBusByOneStop,
|
|
119
|
-
findBusByTwoStop,
|
|
120
|
-
findBusDetailById,
|
|
121
|
-
findBusAll,
|
|
122
|
-
findOperatorAll,
|
|
123
|
-
findZoneAll,
|
|
124
|
-
findBusDetailByOperator,
|
|
125
|
-
findOpenHoursAll
|
|
126
|
-
};
|
|
117
|
+
}
|
package/tsconfig.json
DELETED
|
File without changes
|