Skip to content

Commit 4e30e10

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 <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 39fbab9 commit 4e30e10

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
const replMap = new WeakMap();
4141

4242
const GLOBAL_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
const GLOBAL_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-
const requireRE = /\brequire\s*\(['"](([\w\.\/-]+\/)?([\w\.\/-]*))/;
786+
const requireRE = /\brequire\s*\(['"](([\w./-]+\/)?([\w./-]*))/;
787787
const simpleExpressionRE =
788788
/(([a-zA-Z_$](?:\w|\$)*)\.)*([a-zA-Z_$](?:\w|\$)*)\.?$/;
789789

@@ -1036,7 +1036,7 @@ function complete(line, callback) {
10361036
var newCompletionGroups = [];
10371037
for (i = 0; i < completionGroups.length; i++) {
10381038
group = completionGroups[i].filter(function(elem) {
1039-
return elem.indexOf(filter) == 0;
1039+
return elem.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-
const scopeVar = /^\s*var\s*([_\w\$]+)(.*)$/m;
1343-
const scopeFunc = /^\s*function\s*([_\w\$]+)/;
1342+
const scopeVar = /^\s*var\s*([\w$]+)(.*)$/m;
1343+
const scopeFunc = /^\s*function\s*([\w$]+)/;
13441344
var matches;
13451345

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

0 commit comments

Comments
 (0)