Socket
Socket
Sign inDemoInstall

websocket-stream

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websocket-stream - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

28

index.js

@@ -10,3 +10,3 @@ var through = require('through2')

var proxy = through(socketWrite, socketEnd)
// use existing WebSocket object that was passed in

@@ -20,3 +20,3 @@ if (typeof target === 'object') {

}
// was already open when passed in

@@ -28,4 +28,4 @@ if (socket.readyState === 1) {

socket.addEventListener("open", onready)
}
}
stream.socket = socket

@@ -36,3 +36,5 @@

socket.addEventListener("message", onmessage)
proxy.destroy = destroy;
function socketWrite(chunk, enc, next) {

@@ -42,3 +44,3 @@ socket.send(chunk)

}
function socketEnd(done) {

@@ -48,3 +50,3 @@ socket.close()

}
function onready() {

@@ -55,11 +57,11 @@ stream.setReadable(proxy)

}
function onclose() {
stream.destroy()
}
function onerror(err) {
stream.destroy(err)
}
function onmessage(event) {

@@ -70,4 +72,8 @@ var data = event.data

}
function destroy() {
socket.close()
}
return stream
}
{
"name": "websocket-stream",
"version": "1.1.0",
"version": "1.1.1",
"description": "Use websockets with the node streams API. Works in browser and node",

@@ -5,0 +5,0 @@ "scripts": {

@@ -74,1 +74,21 @@ var test = require('tape')

});
test('destroy', function(t) {
t.plan(1)
echo.start(function() {
var client = websocket(echo.url, echo.options)
client.on('close', function() {
echo.stop(function() {
t.pass('destroyed')
})
})
setTimeout(function() {
client.destroy();
}, 200);
});
});
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