{"id":20808377,"url":"https://github.com/std4453/x-platform-ws","last_synced_at":"2026-04-29T03:03:08.152Z","repository":{"id":57400806,"uuid":"136999956","full_name":"std4453/x-platform-ws","owner":"std4453","description":"A cross-platform wrapper over ws and WebSocket","archived":false,"fork":false,"pushed_at":"2018-06-15T02:53:56.000Z","size":134,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T17:46:37.922Z","etag":null,"topics":["cross-platform","isomorphic","websocket"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/std4453.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-12T01:23:44.000Z","updated_at":"2018-06-15T02:53:57.000Z","dependencies_parsed_at":"2022-09-05T03:50:24.733Z","dependency_job_id":null,"html_url":"https://github.com/std4453/x-platform-ws","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/std4453%2Fx-platform-ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/std4453%2Fx-platform-ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/std4453%2Fx-platform-ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/std4453%2Fx-platform-ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/std4453","download_url":"https://codeload.github.com/std4453/x-platform-ws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243152862,"owners_count":20244662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","isomorphic","websocket"],"created_at":"2024-11-17T19:48:12.076Z","updated_at":"2025-12-28T06:12:31.177Z","avatar_url":"https://github.com/std4453.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# x-platform-ws\n\nThe cross-platform `WebSocket` wrapper in Javascript, imitating the API of the `ws` package on browser.\n\n## Installation\n\nFirst make sure you have `node` and `npm` (Comes with [Node](https://nodejs.org)) installed, then run:\n\n```console\n  $ npm install x-platform-ws --save\n```\n\nBingo! You're made it!\n\n### Further information\n\nIf you are `x-platform-ws` in a project with [browserify](http://browserify.org/) or [webpack](https://webpack.js.org/), everything will be working fine.\n\nIf not, you should add `events` and `buffer` to your dependencies. They are peer dependencies of `x-platform-ws` so you have to install them manually. (Webpack and browserify have them installed and automatically bundled for browsers)\n\n## Usage\n\n```javascript\n  const WebSocket = require('x-platform-ws');\n  const ws = new WebSocket('wss://echo.websocket.org');\n  ws.on('message', data =\u003e console.log(data));\n  ws.on('open', () =\u003e console.log('Opened!'));\n  ws.on('close', (code, reason) =\u003e console.log(`Closed: code=${code}, reason=${reason}`));\n  setTimeout(() =\u003e ws.close(), 10000);\n```\n\nIt is almost compatible with the client in the [`ws`](https://github.com/websockets/ws) package, with some noticable differences:\n- The `options` parameter of the `WebSocket` constructor is only effective on the node side.\n- The `ping()` and `pong()` methods are not supported in the browser. See [this SO thread](https://stackoverflow.com/questions/10585355/sending-websocket-ping-pong-frame-from-browser) for explanations.\n- The [UNIX domain sockets](https://en.wikipedia.org/wiki/Unix_domain_socket) are not supported in the browser.\n- The `'fragment'` [`binaryType`](https://github.com/websockets/ws/blob/master/doc/ws.md#websocketbinarytype) is not supported on the browser.\n- The `'ping'`, `'pong'`, `'unexpected-response'` and `'upgrade'` events are not supported on the browser.\n- The `send()` method does not take advantage of the `options` and the `callback` is invoked immediately.\n\nFor the `ws` api, see [the official docs](https://github.com/websockets/ws/blob/master/doc/ws.md).\n\n## Features\n\n- Support using `'nodebuffer'` as `binaryType` with almost 100% compatibility. (Thanks to the `buffer` npm package)\n- Support using `on()`, `once()` and other methods of the Node `EventEmitter` class. (Thanks to the `events` npm package)\n\n## Development\n\nFirst clone the repository:\n\n```console\n  $ git clone https://github.com/std4453/x-platform-ws\n```\nThen, change to working dir:\n\n```console\n  $ cd x-platform-ws\n```\n\nAnd:\n\n```console\n  $ npm install\n```\n\nNow play with it as you like!\n\n## Versioning\n\nWe use [semantic versioning](https://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/std4453/x-platform-ws/tags).\n\n## Authors\n\n- __std4453__ - [me@std4453.com](mailto:me@std4453.com)\n\n## License\n\nThis project is licensed under the MIT License, see [LICENSE](https://github.com/std4453/x-platform-ws/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstd4453%2Fx-platform-ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstd4453%2Fx-platform-ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstd4453%2Fx-platform-ws/lists"}