isomorphic-ws
Advanced tools
Comparing version 3.2.0 to 4.0.0
{ | ||
"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); | ||
}); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1604
43
+ Addedws@8.18.0(transitive)
- Removedws@3.2.0
- Removedasync-limiter@1.0.1(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedultron@1.1.1(transitive)
- Removedws@3.2.0(transitive)