iojs/io.js — pull request #214 by brendanashworth (2014-12-29 20:27:19+00:00)
Title: dgram: return self on .bind() and .close()

These commits add two functionalities to the `lib/dgram.js` library: a datagram Socket should return itself when it is both closed and bound to a host.

This can be used for better chaining of functions, i.e.:
```javascript
var socket = dgram.createSocket('udp4').bind(1234);
```

I ran across this when I was working with the datagram module and chained it like above ^, expecting it to behave like the net module does. These two commits basically make it function like the net module now.

```
> var net = require('net'); var dgram = require('dgram');
undefined
> var server = net.createServer(function() {});
undefined
> var socket = dgram.createSocket('udp4');
undefined
> server.listen(8124) == server;
true
> socket.bind(8124) == socket;
false
```

I also added tests, I hope those tests are satisfactory, and should this be merged into io.js I'll send a PR into node.js.