Skip to content

Commit a41655f

Browse files
author
RyLee Harrison
committed
updated: newest widely supported javascript spec
1 parent 739e559 commit a41655f

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ The API is the same as [MQTT.js](https://github.com/mqttjs/MQTT.js#api), except
3131
## Example
3232

3333
```javascript
34-
var MQTT = require("async-mqtt");
34+
const MQTT = require("async-mqtt");
3535

36-
var client = MQTT.connect("tcp://somehost.com:1883");
36+
const client = MQTT.connect("tcp://somehost.com:1883");
3737

3838
// When passing async functions as event listeners, make sure to have a try catch block
39-
client.on("connect", doStuff);
4039

41-
async function doStuff() {
40+
const doStuff = async () => {
4241

4342
console.log("Starting");
4443
try {
@@ -53,18 +52,20 @@ async function doStuff() {
5352
process.exit();
5453
}
5554
}
55+
56+
client.on("connect", doStuff);
5657
```
5758

5859
## Wrapping existing client
5960

6061
```javascript
61-
var AsyncClient = require("async-mqtt").AsyncClient;
62+
const { AsyncClient } = require("async-mqtt");
6263

63-
var client = getRegularMQTTClientFromSomewhere();
64+
const client = getRegularMQTTClientFromSomewhere();
6465

65-
var asyncClient = new AsyncClient(client);
66+
const asyncClient = new AsyncClient(client);
6667

67-
asyncClient.publish("foo/bar", "baz").then(function(){
68+
asyncClient.publish("foo/bar", "baz").then(() => {
6869
console.log("We async now");
6970
return asyncClient.end();
7071
});

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const mqtt = require('mqtt');
2+
23
const RegularClientPrototype = mqtt.MqttClient.prototype;
34

45
class AsyncClient {

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
},
2525
"homepage": "https://github.com/mqttjs/async-mqtt#readme",
2626
"dependencies": {
27-
"in-array": "^0.1.2",
2827
"mqtt": "^2.3.1"
2928
},
3029
"devDependencies": {

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function buildServer () {
132132

133133
client.on('subscribe', ({messageId, subscriptions}) => {
134134
client.suback({
135-
messageId: messageId,
135+
messageId,
136136
granted: subscriptions.map(({qos}) => qos)
137137
})
138138
})

0 commit comments

Comments
 (0)