{"name":"async-mqtt","version":"2.6.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":"^4.1.0"},"devDependencies":{"@types/node":"^14.0.5","eslint":"^7.1.0","mqtt-connection":"^4.0.0","tape":"^5.0.0"},"gitHead":"86659ac89d1d549f71f0dd4152241c5f801ec06e","_id":"async-mqtt@2.6.0","_nodeVersion":"12.16.2","_npmVersion":"6.14.4","dist":{"integrity":"sha512-d0gBndMezG15jWCMwkQYf9iRkq4wOl8rsIhMb0y4xrEiH5QFP7qMgrb4o42INi/JXjLMqph141FnQw/queItYQ==","shasum":"96fde8bbce0ec3b10c0a537847e402f6ba685d23","tarball":"http://registry-npm.ywwl.com/async-mqtt/download/async-mqtt-2.6.0.tgz","fileCount":7,"unpackedSize":17156,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeytUqCRA9TVsSAnZWagAABVQP/RnnizhdbNVTXy4MCBoL\ncnyB6Jn38y0aDo2nsqgJcrzRZIqO/4VKrACgeltcL6i92zWZwhSKHVuY7BQw\nfTq/mscL8eAuOFan+37LF2JR8tlZWPdSEjCzojCtuRzMvuMuXlw6vsvtM83r\nMdBKdmKndFbWTRbuqp1hkL37jPdHVpeZR9SP3d7Vo+U1L0opjhIYElbeTGrA\nPUmXVk/xsc84Rt5JtnlvvSJggQaVTn4RW7By9wYuz/IoA/Je3PSF5U4W6BdP\nuoArM4wT/S7983r9ZJ162SaNS0YVJhSrtbBdcMbI4t/eUl10sOI4eRnKrYjj\nICp1rA6cKIkshZJ5u14EOMi8amVqhHxzcv1TVL+mj6pnGQ7OiJzj62Cxtyhg\nqFJCnZTREYtZQSMnMATdDwMSw5KAXN8oO07v1JFbm6lMWg2fPqk7GlrQGqSR\n0nCn/t7X0xefR3IMZOO7tiM56V6ht9UOzCc33kB2UTFUY5lBzCS604j7sIKl\nhe7Su96/mG2WSQez1/iOmlGn8f2597w39BCTj8aF1kzfB7588yYSMacEci77\npwdp8/eqTZ1+hRNkgDuzQmXRSLfeeTy88NdwzssbMroeCHGnVbAU2wQv0oPC\n4NWipgImSIY8XSR23v5ktA+XIrDigAgIVEdSWuE4ePBzNm0DkwIRgnmn6UsH\ndNvj\r\n=brSl\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBzueDSOpep0nRTU4tMwani8MVPQY9mtF/Dulu0IfefgAiEAggXIAglg8cTGQh2vOfSg34NWApZv7A13n0qCeA4cwX0="}],"size":4850,"noattachment":false,"key":"/async-mqtt/-/async-mqtt-2.6.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.6.0_1590351145744_0.9542047080508389"},"_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":1590351145849,"_cnpm_publish_time":1590351145849,"dist-tags":{"latest":"2.6.3"}}