Socket
Socket
Sign inDemoInstall

websocket-stream

Package Overview
Dependencies
Maintainers
3
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.3.0 to 1.3.1

2

package.json
{
"name": "websocket-stream",
"version": "1.3.0",
"version": "1.3.1",
"description": "Use websockets with the node streams API. Works in browser and node",

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

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

var stream, socket
var socketWrite = process.title === 'browser' ? socketWriteBrowser : socketWriteNode
var proxy = through(socketWrite, socketEnd)

@@ -37,6 +38,16 @@

function socketWrite(chunk, enc, next) {
function socketWriteNode(chunk, enc, next) {
socket.send(chunk, next)
}
function socketWriteBrowser(chunk, enc, next) {
try {
socket.send(chunk)
} catch(err) {
return next(err)
}
next()
}
function socketEnd(done) {

@@ -43,0 +54,0 @@ socket.close()

@@ -13,1 +13,15 @@ var ws = require('./')

})
test('echo works two times', function(t) {
var stream = ws('ws://localhost:8343')
stream.once('data', function(o) {
t.equal(o.toString(), 'hello', 'got first hello back')
stream.write(new Buffer('hello'))
stream.once('data', function(o) {
t.equal(o.toString(), 'hello', 'got second hello back')
stream.destroy()
t.end()
})
})
stream.write(new Buffer('hello'))
})
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