dgram: changes Socket.close() to return itself
authorBrendan Ashworth <squirrelslikeacorns@gmail.com>
Mon, 29 Dec 2014 20:12:30 +0000 (12:12 -0800)
committerBen Noordhuis <info@bnoordhuis.nl>
Mon, 29 Dec 2014 16:25:45 +0000 (17:25 +0100)
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>
lib/dgram.js
test/parallel/test-dgram-close.js

index 6b1772e6128dba410fc09cec7d8b69d2a632854e..ac7a054a4c468139fb3ca462f0332dec9589cc42 100644 (file)
@@ -358,6 +358,8 @@ Socket.prototype.close = function() {
   this._handle.close();
   this._handle = null;
   this.emit('close');
+
+  return this;
 };
 
 
index 77af6f13b8011e036fb34efc05d4ce84f709d77a..1eed54c91f4106edde09136a5aed3e9fa35e4e91 100644 (file)
@@ -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