hk-bus-eta 1.7.3 → 1.7.4

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/Kmb.js +10 -6
  2. package/index.js +5 -5
  3. package/package.json +1 -1
package/Kmb.js CHANGED
@@ -5,11 +5,15 @@ module.exports = {
5
5
  fetchEtas: ({stopId, route, seq, serviceType, bound}) => (
6
6
  fetch(`https://data.etabus.gov.hk/v1/transport/kmb/eta/${stopId}/${route}/${serviceType}`,{
7
7
  cache: utils.isSafari ? 'default' : 'no-store'
8
- }).then( response => response.json() )
9
- .then(({data}) => data.filter(e =>
10
- e.dir === bound
11
- && e.seq === seq + 1 // api return 1-based seq
12
- ).map(e => ({
8
+ })
9
+ .then( response => response.json() )
10
+ .then(({data}) => (
11
+ data.filter(e =>
12
+ e.eta !== null
13
+ && e.dir === bound
14
+ && e.seq === seq + 1 // api return 1-based seq
15
+ )
16
+ .map(e => ({
13
17
  eta: e.eta,
14
18
  remark: {
15
19
  zh: e.rmk_tc,
@@ -17,7 +21,7 @@ module.exports = {
17
21
  },
18
22
  co: 'kmb'
19
23
  }))
20
- )
24
+ ))
21
25
  ),
22
26
  fetchStopEtas: ( stopId ) => (
23
27
  fetch(`https://data.etabus.gov.hk/v1/transport/kmb/stop-eta/${stopId}`, {
package/index.js CHANGED
@@ -14,11 +14,11 @@ module.exports = {
14
14
  for ( const company_id of co ) {
15
15
  if (company_id === 'kmb' && stops.kmb ){
16
16
  _etas = _etas.concat( await KmbApi.fetchEtas({
17
- route,
18
- stopId: stops.kmb[seq],
19
- seq,
20
- serviceType, bound: bound[company_id]})
21
- )
17
+ route,
18
+ stopId: stops.kmb[seq],
19
+ seq,
20
+ serviceType, bound: bound[company_id]
21
+ }))
22
22
  } else if ( company_id === 'ctb' && stops.ctb ) {
23
23
  _etas = _etas.concat( await CtbApi.fetchEtas({stopId: stops.ctb[seq], route, bound: bound[company_id], seq }))
24
24
  } else if ( company_id === 'nwfb' && stops.nwfb ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hk-bus-eta",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "description": "Query the ETA (Estimated Time of Arrival) of HK Bus",
5
5
  "main": "index.js",
6
6
  "scripts": {