websocket-stream
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -5,3 +5,5 @@ ## Collaborators | ||
<table><tbody><tr><th align="left">maxogden</th><td><a href="https://github.com/maxogden">GitHub/maxogden</a></td></tr> | ||
<table><tbody><tr><th align="left">gst</th><td><a href="https://github.com/gst">GitHub/gst</a></td></tr> | ||
<tr><th align="left">maxogden</th><td><a href="https://github.com/maxogden">GitHub/maxogden</a></td></tr> | ||
<tr><th align="left">deanlandolt</th><td><a href="https://github.com/deanlandolt">GitHub/deanlandolt</a></td></tr> | ||
<tr><th align="left">mcollina</th><td><a href="https://github.com/mcollina">GitHub/mcollina</a></td></tr> | ||
@@ -8,0 +10,0 @@ <tr><th align="left">jnordberg</th><td><a href="https://github.com/jnordberg">GitHub/jnordberg</a></td></tr> |
{ | ||
"name": "websocket-stream", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"license": "BSD-2-Clause", | ||
@@ -5,0 +5,0 @@ "description": "Use websockets with the node streams API. Works in browser and node", |
@@ -9,3 +9,6 @@ var through = require('through2') | ||
var stream, socket | ||
var socketWrite = process.title === 'browser' ? socketWriteBrowser : socketWriteNode | ||
var isBrowser = process.title === 'browser' | ||
var isNative = !!global.WebSocket | ||
var socketWrite = isBrowser ? socketWriteBrowser : socketWriteNode | ||
var proxy = through.obj(socketWrite, socketEnd) | ||
@@ -23,2 +26,3 @@ | ||
var bufferSize = options.browserBufferSize || 1024 * 512 | ||
// browser only: how long to wait when throttling | ||
@@ -32,3 +36,10 @@ var bufferTimeout = options.browserBufferTimeout || 1000 | ||
} else { | ||
socket = new WS(target, protocols, options) | ||
// special constructor treatment for native websockets in browsers, see | ||
// https://github.com/maxogden/websocket-stream/issues/82 | ||
if (isNative && isBrowser) { | ||
socket = new WS(target, protocols) | ||
} else { | ||
socket = new WS(target, protocols, options) | ||
} | ||
socket.binaryType = 'arraybuffer' | ||
@@ -35,0 +46,0 @@ } |
19
test.js
@@ -98,2 +98,21 @@ var test = require('tape') | ||
test('drain', function(t) { | ||
t.plan(1) | ||
echo.start(function() { | ||
var client = websocket(echo.url, echo.options) | ||
client.on('drain', function() { | ||
client.destroy() | ||
echo.stop(function() { | ||
t.pass('drained') | ||
}) | ||
}) | ||
// write until buffer is full | ||
while (client.write('foobar')) {} | ||
}) | ||
}) | ||
test('emit sending errors if the socket is closed by the other party', function(t) { | ||
@@ -100,0 +119,0 @@ |
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
15633
362