Permalink
Browse files

lib: more consistent use of module.exports = {} model

Switch to using the more efficient module.exports = {}
where possible.

PR-URL: #11406
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information...
jasnell committed Feb 15, 2017
1 parent 88c3f57 commit 62e96096faf5ebe159352e19dad7d39073e5bd21
Showing with 23 additions and 15 deletions.
  1. +5 −1 lib/internal/buffer.js
  2. +7 −7 lib/internal/child_process.js
  3. +6 −5 lib/internal/fs.js
  4. +5 −2 lib/internal/net.js
View
@@ -12,7 +12,7 @@ const { isUint8Array } = process.binding('util');
// Transcodes the Buffer from one encoding to another, returning a new
// Buffer instance.
exports.transcode = function transcode(source, fromEncoding, toEncoding) {
function transcode(source, fromEncoding, toEncoding) {
if (!isUint8Array(source))
throw new TypeError('"source" argument must be a Buffer or Uint8Array');
if (source.length === 0) return Buffer.alloc(0);
@@ -28,4 +28,8 @@ exports.transcode = function transcode(source, fromEncoding, toEncoding) {
err.code = code;
err.errno = result;
throw err;
}
module.exports = {
transcode
};
@@ -22,13 +22,6 @@ const errnoException = util._errnoException;
const SocketListSend = SocketList.SocketListSend;
const SocketListReceive = SocketList.SocketListReceive;
module.exports = {
ChildProcess,
setupChannel,
_validateStdio,
getSocketList
};
// this object contain function to convert TCP objects to native handle objects
// and back again.
const handleConversion = {
@@ -900,3 +893,10 @@ function maybeClose(subprocess) {
subprocess.emit('close', subprocess.exitCode, subprocess.signalCode);
}
}
module.exports = {
ChildProcess,
setupChannel,
_validateStdio,
getSocketList
};
View
@@ -20,7 +20,6 @@ function assertEncoding(encoding) {
throw new Error(`Unknown encoding: ${encoding}`);
}
}
exports.assertEncoding = assertEncoding;
function stringToFlags(flag) {
if (typeof flag === 'number') {
@@ -54,7 +53,6 @@ function stringToFlags(flag) {
throw new Error('Unknown file open flag: ' + flag);
}
exports.stringToFlags = stringToFlags;
// Temporary hack for process.stdout and process.stderr when piped to files.
function SyncWriteStream(fd, options) {
@@ -95,6 +93,9 @@ SyncWriteStream.prototype.destroy = function() {
return true;
};
exports.SyncWriteStream = SyncWriteStream;
exports.realpathCacheKey = Symbol('realpathCacheKey');
module.exports = {
assertEncoding,
stringToFlags,
SyncWriteStream,
realpathCacheKey: Symbol('realpathCacheKey')
};
View
@@ -1,7 +1,5 @@
'use strict';
module.exports = { isLegalPort, assertPort };
// Check that the port number is not NaN when coerced to a number,
// is an integer and that it falls within the legal range of port numbers.
function isLegalPort(port) {
@@ -16,3 +14,8 @@ function assertPort(port) {
if (typeof port !== 'undefined' && !isLegalPort(port))
throw new RangeError('"port" argument must be >= 0 and < 65536');
}
module.exports = {
isLegalPort,
assertPort
};

0 comments on commit 62e9609

Please sign in to comment.