hk-bus-eta 1.9.2 → 1.9.3

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.
Files changed (3) hide show
  1. package/index.js +0 -3
  2. package/package.json +2 -2
  3. package/Nwfb.js +0 -48
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const KmbApi = require('./Kmb')
2
- const NwfbApi = require('./Nwfb')
3
2
  const CtbApi = require('./Ctb')
4
3
  const NlbApi = require('./Nlb')
5
4
  const LrtfeederApi = require('./Lrtfeeder')
@@ -22,8 +21,6 @@ module.exports = {
22
21
  }))
23
22
  } else if ( company_id === 'ctb' && stops.ctb ) {
24
23
  _etas = _etas.concat( await CtbApi.fetchEtas({stopId: stops.ctb[seq], route, bound: bound[company_id], seq }))
25
- } else if ( company_id === 'nwfb' && stops.nwfb ) {
26
- _etas = _etas.concat( await NwfbApi.fetchEtas({stopId: stops.nwfb[seq], route, bound: bound[company_id], seq }))
27
24
  } else if ( company_id === 'nlb' && stops.nlb ) {
28
25
  _etas = _etas.concat( await NlbApi.fetchEtas({stopId: stops.nlb[seq], nlbId}) )
29
26
  } else if ( company_id === 'lrtfeeder' && stops.lrtfeeder ) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hk-bus-eta",
3
- "version": "1.9.2",
4
- "description": "Query the ETA (Estimated Time of Arrival) of HK Bus",
3
+ "version": "1.9.3",
4
+ "description": "Query the ETA (Estimated Time of Arrival) of HK Bus/Minibus/Lightrail",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "node test.js"
package/Nwfb.js DELETED
@@ -1,48 +0,0 @@
1
- const utils = require('./utils');
2
-
3
- module.exports = {
4
- co: 'nwfb',
5
- fetchEtas: ({stopId, route, bound, seq }) => (
6
- fetch(`https://rt.data.gov.hk//v2/transport/citybus/eta/CTB/${stopId}/${route}`, {
7
- cache: utils.isSafari ? 'default' : 'no-store'
8
- }).then(
9
- response => response.json()
10
- ).then(({data}) => (
11
- data
12
- .filter(eta => eta.eta && bound.includes(eta.dir))
13
- // filter the eta by the stop sequence information
14
- // as the route data may not 100% match
15
- // use the nearest seq
16
- .sort((a,b) => Math.abs(a.seq - seq) < Math.abs(b.seq - seq) ? -1 : 1 )
17
- .filter((eta, idx, self) => eta.seq === self[0].seq)
18
- .map(e => ({
19
- eta: e.eta,
20
- remark: {
21
- zh: e.rmk_tc,
22
- en: e.rmk_en
23
- },
24
- co: 'nwfb'
25
- }))
26
- ))
27
- ),
28
- fetchStopEtas: ( stopId ) => (
29
- fetch(`https://rt.data.gov.hk/v1/transport/batch/stop-eta/CTB/${stopId}`, {
30
- cache: utils.isSafari ? 'default' : 'no-store'
31
- }).then(
32
- response => response.json()
33
- ).then(({data}) => data.map( e => ({
34
- route: e.route,
35
- bound: e.dir,
36
- seq: e.seq,
37
- eta: e.eta,
38
- dest: {
39
- en: e.dest.replace('/','/')
40
- },
41
- remark: {
42
- en: e.rmk
43
- },
44
- serviceType: 1,
45
- co: 'nwfb'
46
- })))
47
- )
48
- }