Socket
Socket
Sign inDemoInstall

isomorphic-ws

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isomorphic-ws - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

17

package.json
{
"name": "isomorphic-ws",
"version": "3.2.0",
"description": "An isomorphic release of https://www.npmjs.com/package/ws",
"version": "4.0.0",
"description": "Isomorphic implementation of WebSocket",
"main": "node.js",

@@ -11,3 +11,10 @@ "browser": "browser.js",

},
"keywords": [],
"keywords": [
"browser",
"browsers",
"isomorphic",
"node",
"websocket",
"ws"
],
"author": "@heineiuo",

@@ -19,4 +26,4 @@ "license": "MIT",

"homepage": "https://github.com/heineiuo/isomorphic-ws#readme",
"dependencies": {
"ws": "3.2.0"
"peerDependencies": {
"ws": "*"
},

@@ -23,0 +30,0 @@ "files": [

# isomorphic-ws
An isomorphic release of https://www.npmjs.com/package/ws
Isomorphic implementation of WebSocket.
It uses:
- [ws](https://github.com/websockets/ws) on Node
- [global.WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) in browsers
## Usage
You need to install both this package and [ws](https://github.com/websockets/ws):
```
> npm i isomorphic-ws ws
```
Then just require this package:
```js
const WebSocket = require('isomorphic-ws')
const ws = new WebSocket('wss://echo.websocket.org/', {
origin: 'https://websocket.org'
});
ws.on('open', function open() {
console.log('connected');
ws.send(Date.now());
});
ws.on('close', function close() {
console.log('disconnected');
});
ws.on('message', function incoming(data) {
console.log(`Roundtrip time: ${Date.now() - data} ms`);
setTimeout(function timeout() {
ws.send(Date.now());
}, 500);
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc