{"name":"async-mqtt","version":"2.4.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":"3f58d16a51bd3649ad3001ebffc387a3a2525d3a","_id":"async-mqtt@2.4.0","_nodeVersion":"11.15.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-tWMq0YZQt9Yz/EdbHp8zDapV5wzKxsM2J46rtnj3D61Ljr5CnRbWhXM1cevT/wV0Az5A8AFq/7Ng6/Hy2D/o2Q==","shasum":"6cc67ccf2524a83af9dc2c463af0743c09b8f162","tarball":"http://registry-npm.ywwl.com/async-mqtt/download/async-mqtt-2.4.0.tgz","fileCount":7,"unpackedSize":16165,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdSz/TCRA9TVsSAnZWagAAtd4P/A/d3EjZh9qIIjrigyF7\nFhPOuHm1/B0VbRGFvT+OirBDwtf5fqjv1fIamvafwY7FzQMW5GL/y2KNNF92\nrXK1Lws3ZHw73ssTqLfUw1g/dqTnTw5lomt2psE+fnjIRBjNy/a5eGMEydyR\n6Ltf1MTRD2Ypz0JZVNp7AG2I5KrS4kKJtlOqOnBvXb0mnkoKP6HkkEgkf1Qh\n8eRog3Ft4OzW3FavLYFW915PR3yXyqiQLDDlfA46hvLDXCzrt1zhWDdlTKMp\nnwDamZ+nJXjAW1dUzIuhjXZXLokX1GIXpbTsBjnUabNY9mS1i3frCEGxoQxh\nEHeIbSuzCugD05xop3KZIeSthPv76zEDb5u/8qzyVUeRMG8UkGH6GOjbdSeT\nrTYz5kSg89jmZdI4bGUlfPuJ9Mz7uozDtWjSe1z/nHVnvBJW1pELQGp5ZZL1\nnlVIlH0m27RxciPQXTDLArZKARPoxLbSOn6n6nj4kW3jyJQPgXqPj/imatVe\nA2U1SL+DQZBZ2i++o+MRbrAjN2TZeU027LaCIhYieaSlgoMPsbChtgURMSBT\nEdVyhoDcVa/SzFkEQytn+0eKq4rNLGpDDtGRqwez/CVZqUAWA8eE//Mi6IEJ\n8WKw5FWJ0o7FVBPB/1F0SPYLCayOsCFs7QP5R8wDabOjwfo66YwXwOiABV0K\nO/UC\r\n=3Yx1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDvr/vFtJlttjZkhfH69TjmI/l04uAurZraPj1F8Uq7YwIgeyAM4M9yO+s8n2h7FSlArzPlpj3N86OTLPgBjB3Yt6A="}],"size":4684,"noattachment":false,"key":"/async-mqtt/-/async-mqtt-2.4.0.tgz"},"maintainers":[{"email":"hello@matteocollina.com","name":"matteo.collina"},{"email":"rangermauve@hotmail.com","name":"rangermauve"},{"email":"iman.tabrizian@gmail.com","name":"tabrizian"}],"_npmUser":{"name":"rangermauve","email":"rangermauve@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-mqtt_2.4.0_1565212626567_0.469430134705177"},"_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":1565212626712,"_cnpm_publish_time":1565212626712,"dist-tags":{"latest":"2.6.3"}}