Skip to content

Commit 60461d2

Browse files
Trottevanlucas
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 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 c2fab3c commit 60461d2

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);
@@ -1341,8 +1341,8 @@ function regexpEscape(s){
13411341
// TODO(princejwesley): Remove it prior to v8.0.0 release
13421342
// Reference: https://github.com/nodejs/node/pull/7829
13431343
REPLServer.prototype.convertToContext=util.deprecate(function(cmd){
1344-
constscopeVar=/^\s*var\s*([_\w\$]+)(.*)$/m;
1345-
constscopeFunc=/^\s*function\s*([_\w\$]+)/;
1344+
constscopeVar=/^\s*var\s*([\w$]+)(.*)$/m;
1345+
constscopeFunc=/^\s*function\s*([\w$]+)/;
13461346
varmatches;
13471347

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

0 commit comments

Comments
(0)