wili 0.5.0 → 0.6.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/README.de.md CHANGED
@@ -3,19 +3,14 @@
3
3
  [![npm](https://flat.badgen.net/npm/license/wili)](https://www.npmjs.org/package/wili)
4
4
  [![npm](https://flat.badgen.net/npm/v/wili)](https://www.npmjs.org/package/wili)
5
5
  [![CI](https://img.shields.io/github/workflow/status/idleberg/node-wili/CI?style=flat-square)](https://github.com/idleberg/node-wili/actions)
6
- [![David](https://flat.badgen.net/david/dep/idleberg/node-wili)](https://david-dm.org/idleberg/node-wili)
7
6
 
8
7
  [English](README.md) | **Deutsch**
9
8
 
10
- Node Wrapper für das Echtzeitdaten API der Wiener Linien
9
+ Node Wrapper für die Echtzeitdaten-API der Wiener Linien
11
10
 
12
11
  ## Installation
13
12
 
14
- `yarn add wili || npm install wili`
15
-
16
- ## Voraussetzungen
17
-
18
- **Hinweis:** Seit November 2019 wird kein gültiger API Key mehr für die Verwendung benötigt. Zuvor erworbene Keys können weiterhin verwendet werden.
13
+ `npm install wili`
19
14
 
20
15
  ## Anwendung
21
16
 
@@ -24,32 +19,39 @@ Beispielanwendung:
24
19
  ```js
25
20
  import { WienerLinien } from 'wili';
26
21
 
27
- // Der API-Key kann weggelassen werden, wenn
28
- // process.env.WIENER_LINIEN_API_KEY gesetzt ist
29
- const wl = new WienerLinien(API_KEY);
22
+ const wili = new WienerLinien();
30
23
 
31
24
  const options = {
32
25
  relatedLine: ['U2', 'U4', 'U6']
33
26
  };
34
27
 
35
28
  // Promise API
36
- wl.trafficInfoList(options)
37
- .then( data => {
29
+ wili.trafficInfoList(options)
30
+ .then( data => {
31
+ console.log(data.trafficInfos);
32
+ })
33
+ .catch( error => {
34
+ console.error(error);
35
+ });
36
+
37
+ // async/await
38
+ try {
39
+ const data = await wili.trafficInfoList(options);
38
40
  console.log(data.trafficInfos);
39
- })
40
- .catch( error => {
41
+ } catch (output) {
41
42
  console.error(error);
42
- });
43
+ }
44
+ ```
43
45
 
44
- // async/await
45
- (async () => {
46
- try {
47
- let data = await wl.trafficInfoList(options);
48
- console.log(data.trafficInfos);
49
- } catch (output) {
50
- console.error(error);
51
- }
52
- })();
46
+ :warning: Für NodeJS-Versionen unterhalb v18, muss die Klasse mit einer `fetch`-Implementierung instanziert werden.
47
+
48
+ **Beispiel**
49
+
50
+ ```js
51
+ import { WienerLinien } from 'wili';
52
+ import fetch from 'isomorphic-fetch';
53
+
54
+ const wili = new WienerLinien(fetch);
53
55
  ```
54
56
 
55
57
  ## API
package/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  [![npm](https://flat.badgen.net/npm/license/wili)](https://www.npmjs.org/package/wili)
4
4
  [![npm](https://flat.badgen.net/npm/v/wili)](https://www.npmjs.org/package/wili)
5
- [![CI](https://img.shields.io/github/workflow/status/idleberg/node-wili/CI?style=flat-square)](https://github.com/idleberg/node-wili/actions)
6
- [![David](https://flat.badgen.net/david/dep/idleberg/node-wili)](https://david-dm.org/idleberg/node-wili)
5
+ [![CI](https://img.shields.io/github/actions/workflow/status/idleberg/node-wili/default.yml?style=flat-square)](https://github.com/idleberg/node-wili/actions)
7
6
 
8
7
  **English** | [Deutsch](README.de.md)
9
8
 
@@ -11,11 +10,7 @@ A Node wrapper for the Wiener Linien public transport API
11
10
 
12
11
  ## Installation
13
12
 
14
- `yarn add wili || npm install wili`
15
-
16
- ## Prerequisites
17
-
18
- **Note:** As of November 2019, a valid API key to access Wiener Linien's real-time data is no longer required. However, if you obtained a key before, you can continue using it.
13
+ `npm install wili`
19
14
 
20
15
  ## Usage
21
16
 
@@ -24,32 +19,39 @@ Example usage in script:
24
19
  ```js
25
20
  import { WienerLinien } from 'wili';
26
21
 
27
- // The API key can be omitted when
28
- // process.env.WIENER_LINIEN_API_KEY is set
29
- const wl = new WienerLinien(API_KEY);
22
+ const wili = new WienerLinien();
30
23
 
31
24
  const options = {
32
25
  relatedLine: ['U2', 'U4', 'U6']
33
26
  };
34
27
 
35
28
  // Promise API
36
- wl.trafficInfoList(options)
37
- .then( data => {
29
+ wili.trafficInfoList(options)
30
+ .then( data => {
31
+ console.log(data.trafficInfos);
32
+ })
33
+ .catch( error => {
34
+ console.error(error);
35
+ });
36
+
37
+ // async/await
38
+ try {
39
+ const data = await wili.trafficInfoList(options);
38
40
  console.log(data.trafficInfos);
39
- })
40
- .catch( error => {
41
+ } catch (output) {
41
42
  console.error(error);
42
- });
43
+ }
44
+ ```
43
45
 
44
- // async/await
45
- (async () => {
46
- try {
47
- let data = await wl.trafficInfoList(options);
48
- console.log(data.trafficInfos);
49
- } catch (output) {
50
- console.error(error);
51
- }
52
- })();
46
+ :warning: For NodeJS versions lower than v18, the class needs to be instantiated with a `fetch`-implementation
47
+
48
+ **Example**
49
+
50
+ ```js
51
+ import { WienerLinien } from 'wili';
52
+ import fetch from 'isomorphic-fetch';
53
+
54
+ const wili = new WienerLinien(fetch);
53
55
  ```
54
56
 
55
57
  ## API