Skip to content
Closed
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
Next Next commit
fixup: smaller code
  • Loading branch information
BridgeAR committed Jan 6, 2019
commit 34a1785abebab38bb1055ef5abb525a143d57c78
7 changes: 3 additions & 4 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ Module._nodeModulePaths = function(from) {
};

// 'node_modules' character codes reversed
const nmChars = [ 115, 101, 108, 117, 100, 111, 109, 95, 101, 100, 111, 110 ];
const nmLen = nmChars.length;
const nmChars = [115, 101, 108, 117, 100, 111, 109, 95, 101, 100, 111, 110];
if (isWindows) {
// 'from' is the __dirname of the module.
getNodeModulePaths = (from) => {
Expand Down Expand Up @@ -344,7 +343,7 @@ if (isWindows) {
if (code === CHAR_BACKWARD_SLASH ||
code === CHAR_FORWARD_SLASH ||
code === CHAR_COLON) {
if (p !== nmLen)
if (p !== nmChars.length)
paths.push(`${from.slice(0, last)}\\node_modules`);
last = i;
p = 0;
Expand Down Expand Up @@ -379,7 +378,7 @@ if (isWindows) {
for (var i = from.length - 1; i >= 0; --i) {
const code = from.charCodeAt(i);
if (code === CHAR_FORWARD_SLASH) {
if (p !== nmLen)
if (p !== nmChars.length)
paths.push(`${from.slice(0, last)}/node_modules`);
last = i;
p = 0;
Expand Down