Skip to content

Upgrade Node module dependencies #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.nyc_output
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
2 changes: 1 addition & 1 deletion duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ function duplex (ws, opts) {
upgrade: req.upgrade,
method: req.method
};
};
}

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@
"dependencies": {
"relative-url": "^1.0.2",
"safe-buffer": "^5.1.1",
"ws": "^1.1.0"
"ws": "^7.1.2"
},
"devDependencies": {
"mapleTree": "^0.5.1",
"pull-goodbye": "~0.0.1",
"pull-json-doubleline": "^1.0.0",
"pull-split": "^0.2.0",
"pull-json-doubleline": "^2.0.0",
"pull-stream": "^3.3.2",
"pull-through": "^1.0.18",
"tap": "^5.7.2",
"tap": "^14.6.4",
"tape": "^4.4.0",
"testling": "^1.7.1",
"wsurl": "^1.0.0"
Expand Down
6 changes: 2 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
var ws = require('./')
var WebSocket = require('ws')
var url = require('url')
var http = require('http')
var https = require('https')

var EventEmitter = require('events').EventEmitter
module.exports = !WebSocket.Server ? null : function (opts, onConnection) {
var emitter = new EventEmitter()
var server
if (typeof opts === 'function'){
onConnection = opts
opts = null
Expand Down Expand Up @@ -38,9 +36,9 @@ module.exports = !WebSocket.Server ? null : function (opts, onConnection) {
proxy(server, 'request')
proxy(server, 'close')

wsServer.on('connection', function (socket) {
wsServer.on('connection', function (socket, req) {
var stream = ws(socket)
stream.remoteAddress = socket.upgradeReq.socket.remoteAddress
stream.remoteAddress = req.socket.remoteAddress
emitter.emit('connection', stream)
})

Expand Down
2 changes: 1 addition & 1 deletion source.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = function(socket, cb) {
else
receiver = cb;

};
}

return read;
};
6 changes: 1 addition & 5 deletions test/error.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var test = require('tape');
var WebSocket = require('ws');
var endpoint = require('./helpers/wsurl') + '/read';
var pull = require('pull-stream');
var ws = require('../');

Expand All @@ -14,7 +13,7 @@ test('test error', function (t) {
pull.values(['x', 'y', 'z']),
pull.through(null, function (err) {
if(_err) {
t.strictEqual(err, _err);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also made this change. I think that err and _err are identical objects, but they were failing because {} !== {}. The actual error is stored in .error, so I've changed this test to compare that property instead.

t.strictEqual(err.error, _err.error);
t.end();
}
_err = err
Expand All @@ -34,14 +33,11 @@ test('test error', function (t) {
//connect to a server that does not exist, and check that it errors.
//should pass the error to both sides of the stream.
test('test error', function (t) {
var _err

ws(new WebSocket('ws://localhost:34897/' + Math.random()),
{onConnect: function (err) {
t.ok(err)
t.end()
}})

})


Expand Down
4 changes: 2 additions & 2 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ var wss = new WebSocketServer({ port: port });
});
});

wss.on('connection', function(ws) {
var match = router.match(ws.upgradeReq.url);
wss.on('connection', function(ws, req) {
var match = router.match(req.url);
if (match && typeof match.fn == 'function') {
match.fn(ws);
}
Expand Down
5 changes: 0 additions & 5 deletions test/ws-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ tape('map from a relative url to one for this domain', function (t) {
})

tape('same path works on dev and deployed', function (t) {
var location = {
protocol: 'http',
host: 'localhost:8000',
}

t.equal(
wsurl('/', {
protocol: 'http',
Expand Down