{"_id":"@arnellebalane/websockets","_rev":"2-67573280cd0696e9ed04aba76ebe218f","name":"@arnellebalane/websockets","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@arnellebalane/websockets","version":"1.0.0","description":"A socket.io-like WebSocket server and client library on top of ws.","main":"build/index.js","scripts":{"prebuild":"rimraf build","build":"npm-run-all --parallel build:*","build:server":"babel --out-dir build index.js","build:client":"webpack --output-filename websockets.umd.js","build:client.min":"NODE_ENV=production webpack --output-filename webpack.umd.min.js","commit":"git-cz"},"keywords":["websockets"],"files":["build","client.js","index.js"],"author":{"name":"Arnelle Balane","email":"arnellebalane@gmail.com","url":"https://arnellebalane.com/"},"license":"MIT","dependencies":{"ws":"5.2.0"},"devDependencies":{"babel-cli":"6.26.0","babel-loader":"7.1.4","babel-preset-env":"1.7.0","commitizen":"2.10.1","cz-conventional-changelog":"2.1.0","npm-run-all":"4.1.3","rimraf":"2.6.2","webpack":"4.12.0","webpack-cli":"3.0.8"},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"babel":{"presets":["env"]},"gitHead":"be034d46d2ef304e422e4fb82adee10b0cf866aa","_id":"@arnellebalane/websockets@1.0.0","_npmVersion":"6.1.0","_nodeVersion":"8.11.1","_npmUser":{"name":"arnellebalane","email":"arnellebalane@gmail.com"},"dist":{"integrity":"sha512-CgGGFt0cZrKvMbWDofwHGloNwpIhezkovDejXXSBoV4a04eAx89Qzgjb+adj6QPyPCnbbrpxqUOzFLXw2mE0Xg==","shasum":"0f1e5458e15cc24c536be6688269ce9b2c7b5f1e","tarball":"https://registry.npmjs.org/@arnellebalane/websockets/-/websockets-1.0.0.tgz","fileCount":8,"unpackedSize":16135,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbJ7jFCRA9TVsSAnZWagAAP1EQAJHl43eL+6+pwEyBm/5q\nm+3+bMiI9HQ/mxOuzCNfPBp9G2GhFdaMVKteHA/BeV3i7AX13FY3kE771hcx\npC64vmQtrTRPzkTShw/ZQZr69vDnaFQOn9rX3/0Sz6m2KoTkLMee7IqrLjCm\ns0IhuujaE5YWRUES2gpK+aEXAT25DS6OS2L+2HlX/9V7ZuuELiSFppHTMWbz\niFuU+P/5dQdA4sNhmOa5WfVnmK0fCbwGgSvbGwQkfRp7/UnD6Cg8R1Qe45GU\nCBq1H9INXLOYCSwXOZVgljX/jVfLXMCG3xC8zijqf/HLG+zePD3kl1K700oe\nDKSvZ7G1ArcBUDe4ctD4jXEs0DBagV943XVnFmy0jI6PcqgSut8As0O24vS1\n6ndsCfgE4SKd2Fh43HWQdVP5mnFKioMfAlH37xdMoI3Qo7pTvLfKWE1rkZO6\nEj158EfgtibSEIxwg249FRvCWOpq2DceA+pYV3ckFq7cMgPcSGMb2C8PIPr4\nPnmm/Ym2AF90k7BglkjodwyoLT54LhmO/KzbdrWO3+Kj6uQl05kWV36iHNrF\nvMKopgl/KI1DKHc+xHyJRwLEr6o3EljXRFwGab18/ddt+01HD1mftmfj6VV4\nVPfl864xOH7eyMM0oEzF/HL9ED7o5ttxrhKP37o58OpLE4ClJeDdGp/G7Mv0\nzmjF\r\n=CNWm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGF1N3qAeugfKNLh8c8529SLr9BfERHeLhDeQ2hrVmNLAiBub4oyzxzZAVOqca8uwYQ0nwVJxBmWKpYUuL+86SN1tg=="}]},"maintainers":[{"name":"arnellebalane","email":"arnellebalane@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/websockets_1.0.0_1529329861291_0.49994644434237423"},"_hasShrinkwrap":false},"1.0.1":{"name":"@arnellebalane/websockets","version":"1.0.1","description":"A socket.io-like WebSocket server and client library on top of ws.","main":"build/index.js","scripts":{"prebuild":"rimraf build","build":"npm-run-all --parallel build:*","build:server":"babel --out-dir build index.js","build:client":"webpack --output-filename websockets.umd.js","build:client.min":"NODE_ENV=production webpack --output-filename webpack.umd.min.js","commit":"git-cz","travis-deploy-once":"travis-deploy-once","semantic-release":"semantic-release"},"keywords":["websockets"],"files":["build","client.js","index.js"],"author":{"name":"Arnelle Balane","email":"arnellebalane@gmail.com","url":"https://arnellebalane.com/"},"license":"MIT","dependencies":{"ws":"5.2.0"},"devDependencies":{"babel-cli":"6.26.0","babel-loader":"7.1.4","babel-preset-env":"1.7.0","commitizen":"2.10.1","cz-conventional-changelog":"2.1.0","npm-run-all":"4.1.3","rimraf":"2.6.2","semantic-release":"^15.5.5","semantic-release-cli":"4.0.5","webpack":"4.12.0","webpack-cli":"3.0.8","travis-deploy-once":"^5.0.0"},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"babel":{"presets":["env"]},"repository":{"type":"git","url":"git+https://github.com/arnellebalane/websockets.git"},"bugs":{"url":"https://github.com/arnellebalane/websockets/issues"},"homepage":"https://github.com/arnellebalane/websockets#readme","gitHead":"58adf33b4f6c8042536817ece2826001da7899a7","_id":"@arnellebalane/websockets@1.0.1","_npmVersion":"6.1.0","_nodeVersion":"9.11.2","_npmUser":{"name":"arnellebalane","email":"arnellebalane@gmail.com"},"dist":{"integrity":"sha512-S6WMuaHZulFDmEMCm58aCVffCJVzNR7WLSKmwp/HJAweFti9wi3IplyzV+lWzTZx+bkcdGziSsEboRwWoy7e1Q==","shasum":"8fa7ab6b2509d3bbbf1948c6e1043acc5be43ace","tarball":"https://registry.npmjs.org/@arnellebalane/websockets/-/websockets-1.0.1.tgz","fileCount":5,"unpackedSize":6973,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbKPsBCRA9TVsSAnZWagAAZzQQAJ48PpCRmbzUGAwzlCAv\nRJFo6WYxFDvqVP/Hj21/tQr1kazlZczTmN2jHdw6EMyodhuYZJGMvc5H5H9J\nU17VyyFuwHDZN1B4EBWzSKYU1pw4Dbef/2g1233Agbbj9UMOOXGynbfOZYvn\nxlLi/Vv+h5OyShrFJxoZ8/J07w0W38V4DoReGfDZqiqb/QW/vl0rkGT8RBeK\nTNYk4WZ62TZhtydY2MgbQBLTk566lEOEDHETs+y9mRLpL4lFGbZq55/evORj\nM9UwnUw+FkoU6wEroI2l3KZ96MUiHbg3QI0WIoxSCs2Zo3wbPNiNkVNUCb7F\nNOgOlyvixBgh5doBC7qc5xXdpeXpvcxRq15KjsvfW1MKz9bhqXxOjIkaTUg6\ngGEWVR2WKFCTx4yMn0NocRy8vje6MnzPHw6R2zZ1UvMec4Q5PtmYVWf8/azg\nqESeg0pvNa7JbKuU/b+KP/WAsp+tQ6xnyAZYQj/5rb+7WriO/rqSbIAHWPLQ\nrrEHNshcvB/QbG3YNSD3jOJY6lN50yEUMwITiZ54r3H44CTGJp3S+LP2cMn3\n0fEPGshcwSpnVJzH6YQe0yD6PgrKAuxH6ZYKIINQKjOcDjRklbMpget5s8yY\n7wuyVFPcVvgVCBrAvPq2XpT6LCOMdZeZXSz2GOqR8FfeWOwfy6rC9T3apjHX\nIpm5\r\n=3ZDd\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBJtCI7JBdy0stci7XPmk/m1S+Akh5Lrbth9g0H0Pvr7AiEA/XGN1wiaX5S+747RXyGIZEjIOfIuwoY/8o8y3Crtejo="}]},"maintainers":[{"name":"arnellebalane","email":"arnellebalane@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/websockets_1.0.1_1529412353131_0.1238337122532518"},"_hasShrinkwrap":false}},"time":{"created":"2018-06-18T13:51:00.991Z","1.0.0":"2018-06-18T13:51:01.370Z","modified":"2022-04-04T15:33:50.014Z","1.0.1":"2018-06-19T12:45:53.227Z"},"maintainers":[{"name":"arnellebalane","email":"arnellebalane@gmail.com"}],"description":"A socket.io-like WebSocket server and client library on top of ws.","keywords":["websockets"],"author":{"name":"Arnelle Balane","email":"arnellebalane@gmail.com","url":"https://arnellebalane.com/"},"license":"MIT","readme":"# websockets\n\nA WebSocket server and client library built on top of [`ws`][1] with a similar\nevent-based mechanism to [`socket.io`][2].\n\n## Installing\n\n```bash\nnpm install @arnellebalane/websockets\n```\n\n## Usage\n\n#### On the server:\n\n```js\nimport websockets from '@arnellebalane/websockets';\n\nconst ws = websockets({\n    server, // An http.Server object\n    path: '/ws'\n});\n\nws.on('connection', socket => {\n    socket.emit('greeting', 'Hello there!');\n\n    socket.on('message', data => {\n        // message === [1, 2, 3]\n    });\n});\n```\n\nIf you are using the usual `require()`, you can load this package through:\n\n```js\nconst websockets = require('@arnellebalane/websockets').default;\n```\n\n#### On the client:\n\n```js\nimport websockets from '@arnellebalane/websockets/client';\n\nconst socket = websockets('ws://hostname/ws');\n\nsocket.on('greeting', data => {\n    // data === 'Hello there!';\n\n    socket.emit('message', [1, 2, 3]);\n});\n```\n\n## API\n\n- `websockets(options)`\n  - Factory method for creating a new WebSocket server.\n  - Under the hood it just creates a new `ws.Server` object, and the `options` parameter passed to it is just passed directory to the `ws.Server` constructor. Refer to the [`ws`][1] docs for what options you can use.\n- `socket`\n  - A wrapper around the native `Socket` object representing the WebSocket connection, adding extra methods to make the event-based API possible.\n  - `socket.emit(name, data)`\n    - If called on the server, an event called `name` will be emitted on the client and the callback receives `data`.\n    - If called on the client, an event called `name` will be emitted on the server and the callback receives `data`.\n    - `name` (String): The name of the event.\n    - `data` (Any): Needs to be a JSON-serializable object.\n  - `socket.on(name, callback)`\n    - `name` (String): The name of the event to listen to.\n    - `callback` (Function)\n      - The function to execute when the event is emitted.\n      - Receives the `data` object from the `socket.emit` call.\n\n## License\n\nMIT License\n\n\n[1]: https://www.npmjs.com/package/ws\n[2]: https://www.npmjs.com/package/socket.io\n","readmeFilename":"readme.md","homepage":"https://github.com/arnellebalane/websockets#readme","repository":{"type":"git","url":"git+https://github.com/arnellebalane/websockets.git"},"bugs":{"url":"https://github.com/arnellebalane/websockets/issues"}}