wifi-on-ice-position-stream
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,3 +6,3 @@ 'use strict' | ||
const createPositionsStream = (interval = 5 * 1000) => { | ||
const createPositionsStream = (interval = 5 * 1000, closeOnTrainChange = false) => { | ||
if ( | ||
@@ -21,2 +21,3 @@ 'number' !== typeof interval || | ||
let lastTzn = null | ||
const fetch = () => { | ||
@@ -27,2 +28,8 @@ const t = Date.now() | ||
.then((data) => { | ||
if (data.tzn && lastTzn && closeOnTrainChange && data.tzn !== lastTzn) { | ||
out.close() | ||
return; | ||
} | ||
lastTzn = data.tzn | ||
data.clientTime = t | ||
@@ -29,0 +36,0 @@ out.push(data) |
@@ -1,2 +0,2 @@ | ||
Copyright (c) 2018, Jannis R | ||
Copyright (c) 2020, Jannis R | ||
@@ -3,0 +3,0 @@ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. |
{ | ||
"name": "wifi-on-ice-position-stream", | ||
"description": "A stream of ICE positions, taken from the on-board WiFi.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": "index.js", | ||
@@ -14,5 +14,3 @@ "files": [ | ||
"movement", | ||
"track", | ||
"gps", | ||
"gpx" | ||
"track" | ||
], | ||
@@ -19,0 +17,0 @@ "author": "Jannis R <mail@jannisr.de>", |
@@ -23,3 +23,3 @@ # wifi-on-ice-position-stream | ||
const positions = createSteam() | ||
const positions = createStream() | ||
positions.once('data', (position) => { | ||
@@ -50,4 +50,17 @@ console.log(position) | ||
## API | ||
```js | ||
createPositionsStream(interval = 5 * 1000, closeOnTrainChange = false) | ||
``` | ||
## Related | ||
- [`wifi-on-ice-portal-client`](https://github.com/derhuerst/wifi-on-ice-portal-client) – Query information from the WifiOnICE portal in German ICE trains. | ||
- [`record-ice-movement`](https://github.com/derhuerst/record-ice-movement) – Record the movement of any ICE using the on-board WiFi. | ||
## Contributing | ||
If you have a question or have difficulties using `wifi-on-ice-position-stream`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/wifi-on-ice-position-stream/issues). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4432
36
65