{"name":"async-mqtt","version":"2.3.0","description":"Promise wrapper over MQTT.js","main":"index.js","types":"index.d.ts","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/mqttjs/async-mqtt.git"},"keywords":["mqtt","promise","async","publish","subscribe"],"author":{"name":"rangermauve"},"license":"MIT","bugs":{"url":"https://github.com/mqttjs/async-mqtt/issues"},"homepage":"https://github.com/mqttjs/async-mqtt#readme","dependencies":{"mqtt":"^2.3.1"},"devDependencies":{"@types/node":"^8.10.21","eslint":"^4.8.0","mqtt-connection":"^3.0.0","tape":"^4.6.3"},"gitHead":"fcc40b5e08f38c9fcaea79bf8a0f879189428781","_id":"async-mqtt@2.3.0","_npmVersion":"6.5.0","_nodeVersion":"11.9.0","_npmUser":{"name":"rangermauve","email":"rangermauve@hotmail.com"},"dist":{"integrity":"sha512-4CopFTWjwgPMK0iG+xI+/cfmJ60U5dnRqaUpgMW6jE7x1PJgQAn0YnjKTUOCh4i54VLPZGX+YrRQ2mDrvZYnJQ==","shasum":"de211b8f7a58a261da51d7c97a95b9332bdffacf","tarball":"http://registry-npm.ywwl.com/async-mqtt/download/async-mqtt-2.3.0.tgz","fileCount":7,"unpackedSize":13833,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc8UrzCRA9TVsSAnZWagAALO8P/iFRyywCbjBtgG+2u26a\nGezXRhskSnxtxB8IAbMy9rX1c2WzU8XoNNPvYO8jCycR+xa574Vloh7/+ZcU\nYfUpeUgYi30roQ0JIIP3L9KyMtbaMXfs1xAPqC85stVXU4iX8FMOPjZC+nF4\nXz62liXw0T26/1SrdJxdP+n+KFHNoA2LEiX8AnGTGMWFpa6KMxgzIidBOIkb\n7VPA84eRPI20UsE7JHNfYE9QuP6KAIgc5bZRcytK6hI8orVsKFZfVRzbItOe\nh1ZpmOfW1hkYvVB09NgLwj/qix7fnbq2sQyi+B8/0WYIkSVDmZdQeH6k/UkU\na1JI6lv/nO9n02uVOJFiDvpI2CtH20ixzDnPWimRibSjijlqDrORfg6Yn8HB\nfwkV20Wbc4FLsDE4eIoaxPZ8aCIDQ/2mYV36DPK2Rn5q/MrFBfAuGufjer9N\nvb/w3KVODEoUNASljZMxVneytas9EHVnwhlJeAFO8XXGZHjpV9GgACe/b4ls\nAysn3kDmaurGsVwr2A0KRCKskkJMWH2NzAuExtSusbccBs0C69N2A5XXwx6+\nclxi33D4wzwjRuHRFdFsIN+8i1ZYhdmqjmwZnzwDDa2A9y2iJKtPczsw9rpV\njjJ0MFrxDebhNOoBgv5ybS/ChoUGdEJbR0F+4WkbyhnW53bBiZNOz4AkaWti\ngluJ\r\n=NuuQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6MXFLmt2NkAJKPeax1wE27xc9rPDeIFjOusXUVGyLmwIhAPK3bAFIQfdvUVVDUA0Y0IJJzujUNNo4p+Er9FB/+YJ0"}],"size":4225,"noattachment":false,"key":"/async-mqtt/-/async-mqtt-2.3.0.tgz"},"maintainers":[{"email":"hello@matteocollina.com","name":"matteo.collina"},{"email":"rangermauve@hotmail.com","name":"rangermauve"},{"email":"iman.tabrizian@gmail.com","name":"tabrizian"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-mqtt_2.3.0_1559317234852_0.443308787035684"},"_hasShrinkwrap":false,"readme":"<h1 align=\"center\">async-mqtt</h1>\n<p align=\"center\">Promise wrapper over MQTT.js</p>\n<p align=\"center\">\n<a href=\"https://github.com/mqttjs/async-mqtt\">\n    <img alt=\"\" src=\"https://david-dm.org/mqttjs/async-mqtt.svg?style=flat-square\">\n</a>\n<a href=\"https://www.npmjs.com/package/async-mqtt\">\n    <img alt=\"\" src=\"https://img.shields.io/npm/dt/async-mqtt.svg?style=flat-square\">\n</a>\n<a href=\"https://www.npmjs.com/package/async-mqtt\">\n    <img alt=\"\" src=\"https://img.shields.io/npm/v/async-mqtt.svg?style=flat-square\">\n</a>\n<br>\n<a href=\"https://github.com/mqttjs/async-mqtt\">\n    <img alt=\"\" src=\"https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\">\n</a>\n</p>\n\n**IMPORTANT: Make sure you handle rejections from returned promises because they won't crash the process**\n\n## API\n\nThe API is the same as [MQTT.js](https://github.com/mqttjs/MQTT.js#api), except the following functions now return promises instead of taking callbacks\n\n- publish\n- subscribe\n- unsubscribe\n- end\n\n\n## Example\n\n```javascript\nconst MQTT = require(\"async-mqtt\");\n\nconst client = MQTT.connect(\"tcp://somehost.com:1883\");\n\n// When passing async functions as event listeners, make sure to have a try catch block\n\nconst doStuff = async () => {\n\n\tconsole.log(\"Starting\");\n\ttry {\n\t\tawait client.publish(\"wow/so/cool\", \"It works!\");\n\t\t// This line doesn't run until the server responds to the publish\n\t\tawait client.end();\n\t\t// This line doesn't run until the client has disconnected without error\n\t\tconsole.log(\"Done\");\n\t} catch (e){\n\t\t// Do something about it!\n\t\tconsole.log(e.stack);\n\t\tprocess.exit();\n\t}\n}\n\nclient.on(\"connect\", doStuff);\n```\n\nAlternately you can skip the event listeners and get a promise.\n\n```js\nconst MQTT = require(\"async-mqtt\");\n\nrun()\n\nasync function run() {\n  const client = await MQTT.connectAsync(\"tcp://somehost.com:1883\")\n\n  console.log(\"Starting\");\n\ttry {\n\t\tawait client.publish(\"wow/so/cool\", \"It works!\");\n\t\t// This line doesn't run until the server responds to the publish\n\t\tawait client.end();\n\t\t// This line doesn't run until the client has disconnected without error\n\t\tconsole.log(\"Done\");\n\t} catch (e){\n\t\t// Do something about it!\n\t\tconsole.log(e.stack);\n\t\tprocess.exit();\n\t}\n}\n\n```\n\n## Wrapping existing client\n\n```javascript\nconst { AsyncClient } = require(\"async-mqtt\");\n\nconst client = getRegularMQTTClientFromSomewhere();\n\nconst asyncClient = new AsyncClient(client);\n\nasyncClient.publish(\"foo/bar\", \"baz\").then(() => {\n\tconsole.log(\"We async now\");\n\treturn asyncClient.end();\n});\n```\n","publish_time":1559317235013,"_cnpm_publish_time":1559317235013,"dist-tags":{"latest":"2.6.3"}}