Skip to content

Commit 3d45b35

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 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
1 parent 0f52358 commit 3d45b35

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
@@ -39,12 +39,12 @@ const parentModule = module;
3939
const replMap = new WeakMap();
4040

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

@@ -622,7 +622,7 @@ ArrayStream.prototype.writable = true;
622622
ArrayStream.prototype.resume = function() {};
623623
ArrayStream.prototype.write = function() {};
624624

625-
const requireRE = /\brequire\s*\(['"](([\w\.\/-]+\/)?([\w\.\/-]*))/;
625+
const requireRE = /\brequire\s*\(['"](([\w./-]+\/)?([\w./-]*))/;
626626
const simpleExpressionRE =
627627
/(([a-zA-Z_$](?:\w|\$)*)\.)*([a-zA-Z_$](?:\w|\$)*)\.?$/;
628628

@@ -870,7 +870,7 @@ REPLServer.prototype.complete = function(line, callback) {
870870
var newCompletionGroups = [];
871871
for (i = 0; i < completionGroups.length; i++) {
872872
group = completionGroups[i].filter(function(elem) {
873-
return elem.indexOf(filter) == 0;
873+
return elem.indexOf(filter) === 0;
874874
});
875875
if (group.length) {
876876
newCompletionGroups.push(group);
@@ -1124,8 +1124,8 @@ function regexpEscape(s) {
11241124
* @return {String} The converted command.
11251125
*/
11261126
REPLServer.prototype.convertToContext = function(cmd) {
1127-
const scopeVar = /^\s*var\s*([_\w\$]+)(.*)$/m;
1128-
const scopeFunc = /^\s*function\s*([_\w\$]+)/;
1127+
const scopeVar = /^\s*var\s*([\w$]+)(.*)$/m;
1128+
const scopeFunc = /^\s*function\s*([\w$]+)/;
11291129
var matches;
11301130

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

0 commit comments

Comments
 (0)