module: refactor internal/module export style
PR-URL: https://github.com/nodejs/node/pull/12644 Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
parent
579ff2a487
commit
ed0716f0e9
@ -1,14 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
makeRequireFunction,
|
||||
stripBOM,
|
||||
stripShebang,
|
||||
addBuiltinLibsToObject
|
||||
};
|
||||
|
||||
exports.requireDepth = 0;
|
||||
|
||||
// Invoke with makeRequireFunction(module) where |module| is the Module object
|
||||
// to use as the context for the require() function.
|
||||
function makeRequireFunction(mod) {
|
||||
@ -85,7 +76,7 @@ function stripShebang(content) {
|
||||
return content;
|
||||
}
|
||||
|
||||
exports.builtinLibs = [
|
||||
const builtinLibs = [
|
||||
'assert', 'buffer', 'child_process', 'cluster', 'crypto', 'dgram', 'dns',
|
||||
'domain', 'events', 'fs', 'http', 'https', 'net', 'os', 'path', 'punycode',
|
||||
'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'tls', 'tty',
|
||||
@ -94,7 +85,7 @@ exports.builtinLibs = [
|
||||
|
||||
function addBuiltinLibsToObject(object) {
|
||||
// Make built-in modules available directly (loaded lazily).
|
||||
exports.builtinLibs.forEach((name) => {
|
||||
builtinLibs.forEach((name) => {
|
||||
// Goals of this mechanism are:
|
||||
// - Lazy loading of built-in modules
|
||||
// - Having all built-in modules available as non-enumerable properties
|
||||
@ -130,3 +121,12 @@ function addBuiltinLibsToObject(object) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = exports = {
|
||||
addBuiltinLibsToObject,
|
||||
builtinLibs,
|
||||
makeRequireFunction,
|
||||
requireDepth: 0,
|
||||
stripBOM,
|
||||
stripShebang
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user