websocket-stream
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"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')) | ||
}) |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11831
289
2