Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
lib: more consistent use of module.exports = {} model
Switch to using the more efficient module.exports = {}
where possible.
  • Loading branch information
jasnell committed Feb 16, 2017
commit be2226254311806a341407ce286992f1d91b7034
6 changes: 5 additions & 1 deletion lib/internal/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -28,4 +28,8 @@ exports.transcode = function transcode(source, fromEncoding, toEncoding) {
err.code = code;
err.errno = result;
throw err;
}

module.exports = {
transcode
};
14 changes: 7 additions & 7 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -891,3 +884,10 @@ function maybeClose(subprocess) {
subprocess.emit('close', subprocess.exitCode, subprocess.signalCode);
}
}

module.exports = {
ChildProcess,
setupChannel,
_validateStdio,
getSocketList
};
11 changes: 6 additions & 5 deletions lib/internal/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function assertEncoding(encoding) {
throw new Error(`Unknown encoding: ${encoding}`);
}
}
exports.assertEncoding = assertEncoding;

function stringToFlags(flag) {
if (typeof flag === 'number') {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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')
};
7 changes: 5 additions & 2 deletions lib/internal/net.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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
};