Skip to content

Commit 6997af7

Browse files
BridgeARMylesBorins
authored andcommitted
repl: upper case comments first char
Backport-PR-URL: #19244 PR-URL: #17919 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Lance Ball <[email protected]>
1 parent f4f0266 commit 6997af7

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

‎lib/repl.js‎

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const kBufferedCommandSymbol = Symbol('bufferedCommand');
7979
constkContextId=Symbol('contextId');
8080

8181
try{
82-
// hack for require.resolve("./relative") to work properly.
82+
// Hack for require.resolve("./relative") to work properly.
8383
module.filename=path.resolve('repl');
8484
}catch(e){
8585
// path.resolve('repl') fails when the current working directory has been
@@ -89,7 +89,7 @@ try{
8989
module.filename=path.resolve(dirname,'repl');
9090
}
9191

92-
// hack for repl require to work properly with node_modules folders
92+
// Hack for repl require to work properly with node_modules folders
9393
module.paths=Module._nodeModulePaths(module.filename);
9494

9595
// If obj.hasOwnProperty has been overridden, then calling
@@ -99,14 +99,12 @@ function hasOwnProperty(obj, prop){
9999
returnObject.prototype.hasOwnProperty.call(obj,prop);
100100
}
101101

102-
103102
// Can overridden with custom print functions, such as `probe` or `eyes.js`.
104103
// This is the default "writer" value if none is passed in the REPL options.
105104
exports.writer=util.inspect;
106105

107106
exports._builtinLibs=internalModule.builtinLibs;
108107

109-
110108
functionREPLServer(prompt,
111109
stream,
112110
eval_,
@@ -149,7 +147,6 @@ function REPLServer(prompt,
149147
varself=this;
150148

151149
self._domain=dom||domain.create();
152-
153150
self.useGlobal=!!useGlobal;
154151
self.ignoreUndefined=!!ignoreUndefined;
155152
self.replMode=replMode||exports.REPL_MODE_SLOPPY;
@@ -162,7 +159,7 @@ function REPLServer(prompt,
162159
// Context id for use with the inspector protocol.
163160
self[kContextId]=undefined;
164161

165-
// just for backwards compat, see github.com/joyent/node/pull/7127
162+
// Just for backwards compat, see github.com/joyent/node/pull/7127
166163
self.rli=this;
167164

168165
constsavedRegExMatches=['','','','','','','','','',''];
@@ -187,8 +184,7 @@ function REPLServer(prompt,
187184
wrappedCmd=true;
188185
}
189186

190-
// first, create the Script object to check the syntax
191-
187+
// First, create the Script object to check the syntax
192188
if(code==='\n')
193189
returncb(null);
194190

@@ -207,13 +203,13 @@ function REPLServer(prompt,
207203
}catch(e){
208204
debug('parse error %j',code,e);
209205
if(wrappedCmd){
206+
// Unwrap and try again
210207
wrappedCmd=false;
211-
// unwrap and try again
212208
code=input;
213209
wrappedErr=e;
214210
continue;
215211
}
216-
// preserve original error for wrapped command
212+
// Preserve original error for wrapped command
217213
consterror=wrappedErr||e;
218214
if(isRecoverableError(error,code))
219215
err=newRecoverable(error);
@@ -321,7 +317,7 @@ function REPLServer(prompt,
321317
if(!input&&!output){
322318
// legacy API, passing a 'stream'/'socket' option
323319
if(!stream){
324-
// use stdin and stdout as the default streams if none were given
320+
// Use stdin and stdout as the default streams if none were given
325321
stream=process;
326322
}
327323
if(stream.stdin&&stream.stdout){
@@ -371,7 +367,7 @@ function REPLServer(prompt,
371367
this.commands=Object.create(null);
372368
defineDefaultCommands(this);
373369

374-
// figure out which "writer" function to use
370+
// Figure out which "writer" function to use
375371
self.writer=options.writer||exports.writer;
376372

377373
if(options.useColors===undefined){
@@ -387,14 +383,14 @@ function REPLServer(prompt,
387383
}
388384

389385
functionfilterInternalStackFrames(error,structuredStack){
390-
// search from the bottom of the call stack to
386+
// Search from the bottom of the call stack to
391387
// find the first frame with a null function name
392388
if(typeofstructuredStack!=='object')
393389
returnstructuredStack;
394390
constidx=structuredStack.reverse().findIndex(
395391
(frame)=>frame.getFunctionName()===null);
396392

397-
// if found, get rid of it and everything below it
393+
// If found, get rid of it and everything below it
398394
structuredStack=structuredStack.splice(idx+1);
399395
returnstructuredStack;
400396
}
@@ -571,7 +567,7 @@ function REPLServer(prompt,
571567
return;
572568
}
573569

574-
// editor mode
570+
// Editor mode
575571
if(key.ctrl&&!key.shift){
576572
switch(key.name){
577573
case'd': // End editor mode
@@ -591,7 +587,7 @@ function REPLServer(prompt,
591587
case'down': // Override next history item
592588
break;
593589
case'tab':
594-
// prevent double tab behavior
590+
// Prevent double tab behavior
595591
self._previousKey=null;
596592
ttyWrite(d,key);
597593
break;
@@ -861,10 +857,8 @@ function complete(line, callback){
861857
}
862858

863859
varcompletions;
864-
865-
// list of completion lists, one for each inheritance "level"
860+
// List of completion lists, one for each inheritance "level"
866861
varcompletionGroups=[];
867-
868862
varcompleteOn,i,group,c;
869863

870864
// REPL commands (e.g. ".break").
@@ -1042,7 +1036,7 @@ function complete(line, callback){
10421036
}
10431037
}
10441038
}catch(e){
1045-
//console.log("completion error walking prototype chain:" + e);
1039+
//console.log("completion error walking prototype chain:" + e);
10461040
}
10471041
}
10481042

@@ -1085,7 +1079,7 @@ function complete(line, callback){
10851079
}
10861080

10871081
if(completionGroups.length){
1088-
varuniq={};// unique completions across all groups
1082+
varuniq={};// Unique completions across all groups
10891083
completions=[];
10901084
// Completion group 0 is the "closest"
10911085
// (least far up the inheritance chain)
@@ -1100,7 +1094,7 @@ function complete(line, callback){
11001094
uniq[c]=true;
11011095
}
11021096
}
1103-
completions.push('');// separator btwn groups
1097+
completions.push('');// Separator btwn groups
11041098
}
11051099
while(completions.length&&completions[completions.length-1]===''){
11061100
completions.pop();
@@ -1167,7 +1161,7 @@ function _memory(cmd){
11671161
self.lines=self.lines||[];
11681162
self.lines.level=self.lines.level||[];
11691163

1170-
// save the line so I can do magic later
1164+
// Save the line so I can do magic later
11711165
if(cmd){
11721166
// TODO should I tab the level?
11731167
constlen=self.lines.level.length ? self.lines.level.length-1 : 0;
@@ -1181,7 +1175,7 @@ function _memory(cmd){
11811175
// Because I can not tell the difference between a } that
11821176
// closes an object literal and a } that closes a function
11831177
if(cmd){
1184-
// going down is{and ( e.g. function(){
1178+
// Going down is{and ( e.g. function(){
11851179
// going up is } and )
11861180
vardw=cmd.match(/{|\(/g);
11871181
varup=cmd.match(/}|\)/g);
@@ -1192,8 +1186,8 @@ function _memory(cmd){
11921186
if(depth){
11931187
(functionworkIt(){
11941188
if(depth>0){
1195-
// going... down.
1196-
// push the line#, depth count, and if the line is a function.
1189+
// Going... down.
1190+
// Push the line#, depth count, and if the line is a function.
11971191
// Since JS only has functional scope I only need to remove
11981192
// "function(){" lines, clearly this will not work for
11991193
// "function()
@@ -1205,16 +1199,16 @@ function _memory(cmd){
12051199
isFunction: /\bfunction\b/.test(cmd)
12061200
});
12071201
}elseif(depth<0){
1208-
// going... up.
1202+
// Going... up.
12091203
varcurr=self.lines.level.pop();
12101204
if(curr){
12111205
vartmp=curr.depth+depth;
12121206
if(tmp<0){
1213-
//more to go, recurse
1207+
// More to go, recurse
12141208
depth+=curr.depth;
12151209
workIt();
12161210
}elseif(tmp>0){
1217-
//remove and push back
1211+
// Remove and push back
12181212
curr.depth+=depth;
12191213
self.lines.level.push(curr);
12201214
}

0 commit comments

Comments
(0)