mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: more consistent use of module.exports = {} model
Switch to using the more efficient module.exports = {}
where possible.
PR-URL: https://github.com/nodejs/node/pull/11406
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
@@ -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')
|
||||
};
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user