Browse Source

dgram: changes Socket.close() to return itself

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: https://github.com/iojs/io.js/pull/214
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
archived-io.js-v0.12
Brendan Ashworth 10 years ago
committed by Ben Noordhuis
parent
commit
4444b7b52c
  1. 2
      lib/dgram.js
  2. 2
      test/parallel/test-dgram-close.js

2
lib/dgram.js

@ -358,6 +358,8 @@ Socket.prototype.close = function() {
this._handle.close();
this._handle = null;
this.emit('close');
return this;
};

2
test/parallel/test-dgram-close.js

@ -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

Loading…
Cancel
Save