{"_id":"@art-of-coding/eshu","_rev":"3-28fb727a12c2c9e8c6fc0ada2bed628a","name":"@art-of-coding/eshu","description":"MQTT with extra flavor","dist-tags":{"latest":"0.0.1-alpha.3"},"versions":{"0.0.1-alpha.1":{"name":"@art-of-coding/eshu","version":"0.0.1-alpha.1","description":"MQTT with extra flavor","author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"license":"MIT","keywords":["mqtt","publish/subscribe","publish","subscribe"],"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":"=>7.10.0"},"repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/eshu.git"},"bugs":{"url":"https://github.com/Art-of-Coding/eshu/issues"},"homepage":"https://github.com/Art-of-Coding/eshu#readme","dependencies":{"@types/node":"^8.0.8","mqtt":"^2.9.1"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"a9caeb43664a598c076923a0e5a3b0d6d2eef932","_id":"@art-of-coding/eshu@0.0.1-alpha.1","_npmVersion":"5.0.0","_nodeVersion":"8.0.0","_npmUser":{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"},"dist":{"integrity":"sha512-pa6VzEF0EYyIgrPX1ZTuiU+/MFBr0NFnNlDgJmFigWbNKeJdz+IYh8Byuf1RmEILPYtRhjKmERSlWbIItfWmBA==","shasum":"1983f9a1a29ecb9bc169913698625f3a7659c208","tarball":"https://registry.npmjs.org/@art-of-coding/eshu/-/eshu-0.0.1-alpha.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFxrRIRJ+78Sifpar8kUAbhx90ajPdckILd67lrUmV3sAiEA7SGXJmqP2P1aJogV0Toh9ZU7AU720BzI1/ZerHZiadY="}]},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eshu-0.0.1-alpha.1.tgz_1499435696734_0.5384791779797524"}},"0.0.1-alpha.2":{"name":"@art-of-coding/eshu","version":"0.0.1-alpha.2","description":"MQTT with extra flavor","author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"license":"MIT","keywords":["mqtt","publish/subscribe","publish","subscribe"],"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":"=>7.10.0"},"repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/eshu.git"},"bugs":{"url":"https://github.com/Art-of-Coding/eshu/issues"},"homepage":"https://github.com/Art-of-Coding/eshu#readme","dependencies":{"@types/node":"^8.0.8","mqtt":"^2.9.1"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"f1e2f5dae3273ca6d6fe0193c6904df154cef0b4","_id":"@art-of-coding/eshu@0.0.1-alpha.2","_npmVersion":"5.0.0","_nodeVersion":"8.0.0","_npmUser":{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"},"dist":{"integrity":"sha512-aab4n9bGeW0as4NV1a3bwhXhIHE45fKyPgZohX+0tHFITZ/oXSl3i7yr96LAf79RgBPs4/l4HoQ12Y4bzOKH8w==","shasum":"a69b4eea442edb8943e8b744907f8f4e31d89f60","tarball":"https://registry.npmjs.org/@art-of-coding/eshu/-/eshu-0.0.1-alpha.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCwdVH4/ZcZWdRSCOfbo2+BANf/eCFgFWfUnnnd1sJ69AIgH0fBesmNiUyYV2DtPNNPUhgIaYiE2b9XF9LTH3rEx1o="}]},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eshu-0.0.1-alpha.2.tgz_1499435802496_0.09535488882102072"}},"0.0.1-alpha.3":{"name":"@art-of-coding/eshu","version":"0.0.1-alpha.3","description":"MQTT with extra flavor","author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"license":"MIT","keywords":["mqtt","publish/subscribe","publish","subscribe"],"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":"=>7.10.0"},"repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/eshu.git"},"bugs":{"url":"https://github.com/Art-of-Coding/eshu/issues"},"homepage":"https://github.com/Art-of-Coding/eshu#readme","dependencies":{"@types/node":"^8.0.8","mqtt":"^2.9.1"},"devDependencies":{"typescript":"^2.4.1"},"gitHead":"91cf66704b517810075cbcde6b16e4e2f4928aea","_id":"@art-of-coding/eshu@0.0.1-alpha.3","_npmVersion":"5.0.3","_nodeVersion":"8.1.3","_npmUser":{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"},"dist":{"integrity":"sha512-bqG69abZwS/MPYjqGkSyMVZVwrntIhLHqq7jDf4c40Ci3IIOmpwI5f2SqNL1xkEddwNN1bXckiql1lhqeRCAAQ==","shasum":"8e5ebf264854cdd2cb470977116aaf79c133d55c","tarball":"https://registry.npmjs.org/@art-of-coding/eshu/-/eshu-0.0.1-alpha.3.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDR/gwO2A0j9YLTLbGvnZYZ7l2/JnHCD+KBdN9K3GT+owIhAK7SggdmCKDrk6RqBECM8XIhcGjPtYFKuiAfC1ClF8PW"}]},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eshu-0.0.1-alpha.3.tgz_1499779254036_0.8847955521196127"}}},"readme":"# Eshu\r\n\r\nEshu is a God of travelers, roads, crossroads, fortune and misfortune.\r\nHe is also a spirit of trickery and chaos who leads mortals to temptation\r\nand possible tribulation in the hopes that the experience will lead ultimately\r\nto their maturation.\r\n\r\nBut in this case, it's just a TypeScript **MQTT library for node.js** with some\r\n**extra flavor**. It can of course also be used in vanilla JS.\r\n\r\n## Install\r\n\r\n```bash\r\nnpm i @art-of-coding/eshu --save\r\n```\r\n\r\n## Example\r\n\r\n### Super Simple Example\r\n\r\nNo flashy things, just the basics:\r\n\r\n```ts\r\nimport * as eshu from '@art-of-coding/eshu'\r\n\r\n// Create a new client\r\nconst client = new eshu.Client()\r\n\r\n// Set a message event handler\r\nclient.on('message', (packet: eshu.IPacket) => {\r\n  console.log(`${packet.topic} says ${packet.payload.toString()}`)\r\n})\r\n\r\n// Connect to the broker\r\nclient.connect('mqtt://example.com').then((connack: eshu.IConnackPacket) => {\r\n  // Subscribe to a topic\r\n  return client.subscribe('some/topic')\r\n}).then(() => {\r\n  // Publish on the same topic\r\n  return client.publish('some/topic', 'Hello, world!')\r\n}).catch((err: Error) => {\r\n  console.error(err)\r\n})\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nsome/topic says Hello, world!\r\n```\r\n\r\n### Router Example\r\n\r\nTo use the full force of Eshu, one would normally use a `Router`.\r\nThe example below demonstrates the `prefix` option and the use of named topic\r\nwildcards.\r\n\r\n```ts\r\nimport * as eshu from '@art-of-coding/eshu'\r\n\r\n// Create a new client\r\nconst client = new eshu.Client()\r\n\r\n// Create a new router\r\nconst router = new eshu.Router(client, {\r\n  prefix: 'router'\r\n})\r\n\r\n// Connect to the broker\r\nclient.connect('mqtt://example.com').then((connack: eshu.IConnackPacket) => {\r\n\r\n  // Subscribe to a topic with a named wildcard (`+topic`)\r\n  return router.subscribe('another/+topic', (packet: eshu.IPacket) => {\r\n    // You can access the named wildcard as packet.params.topic\r\n    console.log(`${packet.topic} says ${packet.payload.toString()}`)\r\n  })\r\n}).then(() => {\r\n  return client.publish('another/diamond', 'Hello, world!')\r\n}).catch((err: Error) => {\r\n  console.error(err)\r\n})\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nrouter/another/diamond says Hello, world!\r\n```\r\n\r\n## Parameter wildcards\r\n\r\nWhen using a `Router`, you can use parameter wildcards in `subscribe`.\r\nThis is an almost verbatim copy of [mqtt-pattern](https://github.com/RangerMauve/mqtt-pattern),\r\nadjusted for TypeScript (as no declaration file is included yet).\r\n\r\n### Single named parameter wildcards\r\n\r\nA single named parameter wildcard uses MQTT's wildcard symbol (`+`) and a name.\r\nWhen a message matching the topic is received, the named parameter is parsed and\r\nmade available through `packet.params`:\r\n\r\n```ts\r\n// Subscribe using two named wildcards\r\nrouter.subscribe('say/+what/to/+name', packet => {\r\n  console.log(`${packet.params.what}, ${packet.params.name}!`)\r\n})\r\n\r\n// Publish an empty object ({}) payload\r\nrouter.publish('say/hello/to/Mike', {})\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nhello, Mike!\r\n```\r\n\r\n## Catch-all named parameter wildcards\r\n\r\nThe catch-all wildcard (`#`) is supported as well. It can only be used at the end\r\nof a topic:\r\n\r\n```ts\r\n// Subscribe using a catch-all wildcard\r\nrouter.subscribe('say/+what/to/#names', packet => {\r\n  console.log(`${packet.params.what}, ${packet.params.names.join(', ')}!`)\r\n})\r\n\r\n// Publish an empty object ({}) payload\r\nrouter.publish('say/hello/to/Mike/Dennis/Franky', {})\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nhello, Mike, Dennis, Franky!\r\n```\r\n\r\nFor more information on using named wildcards, see [mqtt-pattern](https://github.com/RangerMauve/mqtt-pattern).\r\n\r\n## API\r\n\r\n> Under construction\r\n\r\n## License\r\n\r\nCopyright 2017 [Michiel van der Velde](http://www.michielvdvelde.nl).\r\n\r\nThis software is licensed under the [MIT License](LICENSE).\r\n","maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"time":{"modified":"2022-04-04T15:35:53.260Z","created":"2017-07-07T13:54:57.715Z","0.0.1-alpha.1":"2017-07-07T13:54:57.715Z","0.0.1-alpha.2":"2017-07-07T13:56:43.508Z","0.0.1-alpha.3":"2017-07-11T13:20:55.019Z"},"homepage":"https://github.com/Art-of-Coding/eshu#readme","keywords":["mqtt","publish/subscribe","publish","subscribe"],"repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/eshu.git"},"author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"bugs":{"url":"https://github.com/Art-of-Coding/eshu/issues"},"license":"MIT","readmeFilename":"README.md"}