Skip to content

Commit

Permalink
dgram: changes Socket.close() to return itself
Browse files Browse the repository at this point in the history
This commit adds a return statement to the dgram.Socket.close()
function that returns itself after it finishes. This follows along
the functionality of the more popular and, dare I say, father-library
`lib/net.js`.

PR-URL: nodejs#214
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
brendanashworth authored and bnoordhuis committed Dec 29, 2014
1 parent 3e0057d commit 4444b7b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ Socket.prototype.close = function() {
this._handle.close();
this._handle = null;
this.emit('close');

return this;
};


Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ buf.fill(42);
var socket = dgram.createSocket('udp4');
var handle = socket._handle;
socket.send(buf, 0, buf.length, common.PORT, 'localhost');
socket.close();
assert.strictEqual(socket.close(), socket);
socket = null;

// Verify that accessing handle after closure doesn't throw
Expand Down

0 comments on commit 4444b7b

Please sign in to comment.