{"name":"async-mqtt","version":"2.0.0","description":"Promise wrapper over MQTT.js","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"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":{"in-array":"^0.1.2","mqtt":"^2.3.1"},"devDependencies":{"eslint":"^4.8.0","mqtt-connection":"^3.0.0","tape":"^4.6.3"},"gitHead":"98cb2e179f1e1a5c5d0f7369899c5053a7573bd7","_id":"async-mqtt@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.9.0","_npmUser":{"name":"rangermauve","email":"rangermauve@hotmail.com"},"maintainers":[{"email":"hello@matteocollina.com","name":"matteo.collina"},{"email":"rangermauve@hotmail.com","name":"rangermauve"},{"email":"iman.tabrizian@gmail.com","name":"tabrizian"}],"dist":{"integrity":"sha512-5Dp4nof95hlRAOgmc5ZxwKAUQ1XLmTULIUFJQf7xNE3B0eTNSB7ya8xzxJyUX3PDBhQCWPlEiyslzGXPqDNB2Q==","shasum":"82c3b494fc890f64fe70b566b7180e01d8a13cc2","tarball":"http://registry-npm.ywwl.com/async-mqtt/download/async-mqtt-2.0.0.tgz","fileCount":6,"unpackedSize":10474,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbm8mlCRA9TVsSAnZWagAAYKUP/3axsx8u7CsylY2W3ZaQ\nIdCCxRL26GgY9ivZ+7Bq/VvEbWPBxsU88uaLbeymixt9fZGIpi9LlY/NTsfS\nsVxUPx3vQK0loqb4tWDgBabi1q03AZ55ObbaZsivMciKeV9zEknxJQCS1Qvb\n4JzbIGKKyMm2oRXu9NmUyCtQGmTQX6cYBbhUMfxuWkcg68I4en/r/Y1n9hdX\nQJN3/xHhTtVjfEG7vWbUtRqxxhlIRHl2WoWRPQuRCklWg4QLvbu8lz1jtX/4\n8Cpq61Jllu5WeT4r06pMYpBY4yGCntZg4bwjT0EKEYcmagRolvz7ann5BJLZ\njF1z8F04eNgezhXiArdRcyrYotWVDh/SB6xOXGBPJdISE6oQRvc3I7Z022Mb\nmKwBcCOylrdOC1KTb5hKZWC3gTVIYw+MdSdzkz7/0uxoLdOy3qRtoDMfkNQP\nE2mvH6KVCu7bHKRlZXFB9s9rblq+Q+mktW7BcpVkfLPl9lMLh4mI9D3cUE50\nxHbz/kH1TAmGU+g32wezkBsl8DVJut3wMoqG/++qFLPCVDUYNUb005rDKQw9\ndpFIUNfeoJwtGg7d6Vk+itfkuh9pExup4MyHnw1PEx/tLoCW/p/2r0/Q2DsR\n3f1/PcNfw1/EAAT14tFXpY6botnc7RvisefgAQVsmzvTwhcHpOVvPrmI0USo\n6TIP\r\n=CveW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDjC/MISC6iVCNXkeK9lObhXP3sDb31EIaNu10SriWO7QIgY05s00aVf1HbvaFqd+UvAZ2P/kKTrbp/6+spE7ntyK4="}],"size":3738,"noattachment":false,"key":"/async-mqtt/-/async-mqtt-2.0.0.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/async-mqtt_2.0.0_1536936357019_0.049032126499766626"},"_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":1536936357155,"_cnpm_publish_time":1536936357155,"dist-tags":{"latest":"2.6.3"}}