Skip to content

Commit

Permalink
module: refactor internal/module export style
Browse files Browse the repository at this point in the history
PR-URL: #12644
Reviewed-By: Brian White <mscdex@mscdex.net>
  • Loading branch information
jasnell committed May 1, 2017
1 parent 579ff2a commit ed0716f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/internal/module.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -130,3 +121,12 @@ function addBuiltinLibsToObject(object) {
});
});
}

module.exports = exports = {
addBuiltinLibsToObject,
builtinLibs,
makeRequireFunction,
requireDepth: 0,
stripBOM,
stripShebang
};

0 comments on commit ed0716f

Please sign in to comment.