Skip to content

Commit

Permalink
dgram: refactor dgram to module.exports
Browse files Browse the repository at this point in the history
Refactor dgram module to use the more efficient
module.exports = {} pattern.

PR-URL: #11696
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
  • Loading branch information
claudiorodriguez authored and italoacasas committed Mar 13, 2017
1 parent 8a1b2b4 commit 2fcefee
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function newHandle(type) {
}


exports._createSocketHandle = function(address, port, addressType, fd, flags) {
function _createSocketHandle(address, port, addressType, fd, flags) {
// Opening an existing fd is not supported for UDP handles.
assert(typeof fd !== 'number' || fd < 0);

Expand All @@ -72,7 +72,7 @@ exports._createSocketHandle = function(address, port, addressType, fd, flags) {
}

return handle;
};
}


function Socket(type, listener) {
Expand All @@ -99,12 +99,11 @@ function Socket(type, listener) {
this.on('message', listener);
}
util.inherits(Socket, EventEmitter);
exports.Socket = Socket;


exports.createSocket = function(type, listener) {
function createSocket(type, listener) {
return new Socket(type, listener);
};
}


function startListening(socket) {
Expand Down Expand Up @@ -561,3 +560,9 @@ Socket.prototype.unref = function() {

return this;
};

module.exports = {
_createSocketHandle,
createSocket,
Socket
};

0 comments on commit 2fcefee

Please sign in to comment.