Skip to content

Commit 70062f7

Browse files
TrottMylesBorins
authored andcommitted
repl: refactor lib/repl.js
* remove unnecessary backslash (`\`) escaping in regular expressions * favor `===` over `==` * multiline arrays indentation consistent with other indentation PR-URL: #9374 Ref: #9747 Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent fb525f1 commit 70062f7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

‎lib/repl.js‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ const parentModule = module;
4040
constreplMap=newWeakMap();
4141

4242
constGLOBAL_OBJECT_PROPERTIES=['NaN','Infinity','undefined',
43-
'eval','parseInt','parseFloat','isNaN','isFinite','decodeURI',
44-
'decodeURIComponent','encodeURI','encodeURIComponent',
45-
'Object','Function','Array','String','Boolean','Number',
46-
'Date','RegExp','Error','EvalError','RangeError',
47-
'ReferenceError','SyntaxError','TypeError','URIError',
48-
'Math','JSON'];
43+
'eval','parseInt','parseFloat','isNaN','isFinite','decodeURI',
44+
'decodeURIComponent','encodeURI','encodeURIComponent',
45+
'Object','Function','Array','String','Boolean','Number',
46+
'Date','RegExp','Error','EvalError','RangeError',
47+
'ReferenceError','SyntaxError','TypeError','URIError',
48+
'Math','JSON'];
4949
constGLOBAL_OBJECT_PROPERTY_MAP={};
5050
GLOBAL_OBJECT_PROPERTIES.forEach((p)=>GLOBAL_OBJECT_PROPERTY_MAP[p]=p);
5151

@@ -783,7 +783,7 @@ ArrayStream.prototype.writable = true;
783783
ArrayStream.prototype.resume=function(){};
784784
ArrayStream.prototype.write=function(){};
785785

786-
constrequireRE=/\brequire\s*\(['"](([\w\.\/-]+\/)?([\w\.\/-]*))/;
786+
constrequireRE=/\brequire\s*\(['"](([\w./-]+\/)?([\w./-]*))/;
787787
constsimpleExpressionRE=
788788
/(([a-zA-Z_$](?:\w|\$)*)\.)*([a-zA-Z_$](?:\w|\$)*)\.?$/;
789789

@@ -1036,7 +1036,7 @@ function complete(line, callback){
10361036
varnewCompletionGroups=[];
10371037
for(i=0;i<completionGroups.length;i++){
10381038
group=completionGroups[i].filter(function(elem){
1039-
returnelem.indexOf(filter)==0;
1039+
returnelem.indexOf(filter)===0;
10401040
});
10411041
if(group.length){
10421042
newCompletionGroups.push(group);
@@ -1339,8 +1339,8 @@ function regexpEscape(s){
13391339
* @return{String} The converted command.
13401340
*/
13411341
REPLServer.prototype.convertToContext=function(cmd){
1342-
constscopeVar=/^\s*var\s*([_\w\$]+)(.*)$/m;
1343-
constscopeFunc=/^\s*function\s*([_\w\$]+)/;
1342+
constscopeVar=/^\s*var\s*([\w$]+)(.*)$/m;
1343+
constscopeFunc=/^\s*function\s*([\w$]+)/;
13441344
varmatches;
13451345

13461346
// Replaces: var foo = "bar" with: self.context.foo = bar;

0 commit comments

Comments
(0)