From 2fcefeeda044dfc0f1b4e83730ed8d22b6caf65e Mon Sep 17 00:00:00 2001 From: Claudio Rodriguez Date: Sun, 5 Mar 2017 16:42:03 +0000 Subject: [PATCH] dgram: refactor dgram to module.exports Refactor dgram module to use the more efficient module.exports = {} pattern. PR-URL: https://github.com/nodejs/node/pull/11696 Reviewed-By: Colin Ihrig Reviewed-By: Timothy Gu Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann Reviewed-By: Ron Korving --- lib/dgram.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/dgram.js b/lib/dgram.js index 69bcf5de10343c..4beb28351910ea 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -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); @@ -72,7 +72,7 @@ exports._createSocketHandle = function(address, port, addressType, fd, flags) { } return handle; -}; +} function Socket(type, listener) { @@ -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) { @@ -561,3 +560,9 @@ Socket.prototype.unref = function() { return this; }; + +module.exports = { + _createSocketHandle, + createSocket, + Socket +};