Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
dgram: change Socket.bind() to return itself
This commit changes `lib/dgram.js` Sockets to, when
they are bound to a port / IP, return themselves. This
is done in order to allow chaining of methods and be
in accordance with the `lib/net.js` library.
  • Loading branch information
brendanashworth committed Dec 29, 2014
commit 57332c05e9962b20a4954fed3ebdc9eb5cda895b
4 changes: 3 additions & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Socket.prototype.bind = function(port /*, address, callback*/) {
if (port instanceof UDP) {
replaceHandle(self, port);
startListening(self);
return;
return self;
}

var address;
Expand Down Expand Up @@ -231,6 +231,8 @@ Socket.prototype.bind = function(port /*, address, callback*/) {
startListening(self);
}
});

return self;
};


Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-dgram-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ socket.on('listening', function () {
socket.close();
});

socket.bind(); // should not throw
var result = socket.bind(); // should not throw

assert.strictEqual(result, socket); // should have returned itself