{"name":"async-mqtt","version":"2.6.3","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.3.7"},"devDependencies":{"@types/node":"^14.0.5","eslint":"^7.32.0","mqtt-connection":"^4.0.0","tape":"^5.0.0"},"gitHead":"48f4e3d49b01119ac8359736695a5bc9ddc0544d","_id":"async-mqtt@2.6.3","_nodeVersion":"18.4.0","_npmVersion":"8.12.1","dist":{"integrity":"sha512-mFGTtlEpOugOoLOf9H5AJyJaZUNtOVXLGGOnPaPZDPQex6W6iIOgtV+fAgam0GQbgnLfgX+Wn/QzS6d+PYfFAQ==","shasum":"257628900a9a25c61a552fb49f9ae368069b2f28","tarball":"http://registry-npm.ywwl.com/async-mqtt/download/async-mqtt-2.6.3.tgz","fileCount":7,"unpackedSize":17071,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF7xLCEb0wT64flAsuvNg3tYfbOyevW3IIxrb+nxXaJBAiEAn52SbbZXZIWSgPaGoT5ZG4OTt2oIbBJsdZFbcElUwE4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjF2vjACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr8vw/8C2+2Ao+b8uXjoAjf9gVAhtRlvte+MvSNdcrwCqD5cmelyx+l\r\niwRNVjrfItPJ/cNLx9Za9m8zZUO6RJOhPPJnMww4Xh2TsohTg8LlvX7V6RYQ\r\n2mwJPGRpM7cRY+kGOcDUs1hWoAqu788ZunAl3g8WKdx61Y6jbtlFdQuJ7P/g\r\nwZ3VIuDmSRRWFnk9Zyf5OqWC7jI/FUeYexVvfeI6B3GebO2rTBzFwDR52LjK\r\nootMZdjzC1eD84kjGFBL8W907gBkBtTXq6K/94rN4qr/0HdQEJZF1S3yfzjt\r\nqOh4HTvnyTLH4SO3zZgIYq8ffgrIejFk/hzFivgwhXxG/53pJEJX34I+0wQK\r\nGJ6dC3LeuxX2/Vl9qtBdVfC7+Chq7hpDyOZXbJbWqHfoJIWzFYi81dOXsydw\r\niEXv1eaAnreFyiftHS4GxNtKWZvtvWRVkBtQN/HpHeT20rWEOgZd9iutNjtw\r\nDKMnmb0+gFsHd1G8TVKJyYBvZ4eEKGF17bc+pq+YnaLU2Zzii6fixYGTMkke\r\njKFep+gr6ICYnb96FKQp6ImVPO9eV4UD9pVt5T4COThV3yWLA4zf5+XHCecE\r\nFT+fo/7LwCq/uBZoUq2eYRNoVbaIpCaUNlRerB0OuRTuyQymzDph4x3iCcE4\r\nXvcmP8p8dr7S69Q0V0pqsHToKpr+LniK3Y4=\r\n=BhWT\r\n-----END PGP SIGNATURE-----\r\n","size":4792,"noattachment":false,"key":"/async-mqtt/-/async-mqtt-2.6.3.tgz"},"_npmUser":{"name":"rangermauve","email":"rangermauve@hotmail.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"rangermauve","email":"rangermauve@hotmail.com"},{"name":"tabrizian","email":"iman.tabrizian@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-mqtt_2.6.3_1662479330916_0.7225931902613152"},"_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":1662479331077,"_cnpm_publish_time":1662479331077,"dist-tags":{"latest":"2.6.3"}}