Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

websocket-stream

Package Overview
Dependencies
Maintainers
1
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 0.3.3 to 0.4.0

37

index.js

@@ -1,3 +0,2 @@

var stream = require('stream')
var util = require('util')
var through = require('through')
var isBuffer = require('isbuffer')

@@ -8,6 +7,7 @@ var WebSocketPoly = require('ws')

if (!(this instanceof WebsocketStream)) return new WebsocketStream(server, options)
stream.Stream.call(this)
this.stream = through(this.write.bind(this), this.end.bind(this))
this.stream.websocketStream = this
this.options = options || {}
this.readable = true
this.writable = true
this._buffer = []

@@ -30,10 +30,10 @@

}
return this.stream
}
util.inherits(WebsocketStream, stream.Stream)
module.exports = WebsocketStream
module.exports.WebsocketStream = WebsocketStream
WebsocketStream.prototype.onMessage = function(e, flags) {
WebsocketStream.prototype.onMessage = function(e) {
var data = e

@@ -46,7 +46,7 @@ if (data.data) data = data.data

this.emit('data', data, flags)
this.stream.queue(data)
}
WebsocketStream.prototype.onError = function(err) {
this.emit('error', err)
this.stream.emit('error', err)
}

@@ -56,4 +56,4 @@

if (this._destroy) return
this.emit('end')
this.emit('close')
this.stream.emit('end')
this.stream.emit('close')
}

@@ -68,4 +68,4 @@

this._buffer = undefined
this.emit('open')
this.emit('connect')
this.stream.emit('open')
this.stream.emit('connect')
if (this._end) this.ws.close()

@@ -89,14 +89,9 @@ }

else
this.emit('error', 'Not connected')
this.stream.emit('error', 'Not connected')
}
WebsocketStream.prototype.end = function(data) {
if (data !== undefined) this.write(data)
if (data !== undefined) this.stream.queue(data)
if (this._open) this.ws.close()
this._end = true
}
WebsocketStream.prototype.destroy = function() {
this._destroy = true
this.ws.close()
}
{
"name": "websocket-stream",
"version": "0.3.3",
"version": "0.4.0",
"description": "websockets with the node stream api. works in browser and node",

@@ -27,3 +27,4 @@ "scripts": {

"isbuffer": "0.0.0",
"ws": "~0.4.30"
"ws": "~0.4.30",
"through": "~2.3.4"
},

@@ -30,0 +31,0 @@ "devDependencies": {

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