| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6997af7 commit 55f7bbb
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -320,15 +320,10 @@ function REPLServer(prompt, | |||
| 320 | 320 | // Use stdin and stdout as the default streams if none were given | |
| 321 | 321 | stream = process; | |
| 322 | 322 | } | |
| 323 | - if (stream.stdin && stream.stdout) { | ||
| 324 | - // We're given custom object with 2 streams, or the `process` object | ||
| 325 | - input = stream.stdin; | ||
| 326 | - output = stream.stdout; | ||
| 327 | - } else { | ||
| 328 | - // We're given a duplex readable/writable Stream, like a `net.Socket` | ||
| 329 | - input = stream; | ||
| 330 | - output = stream; | ||
| 331 | - } | ||
| 323 | + // We're given a duplex readable/writable Stream, like a `net.Socket` | ||
| 324 | + // or a custom object with 2 streams, or the `process` object | ||
| 325 | + input = stream.stdin || stream; | ||
| 326 | + output = stream.stdout || stream; | ||
| 332 | 327 | } | |
| 333 | 328 | ||
| 334 | 329 | self.inputStream = input; | |
@@ -663,7 +658,7 @@ REPLServer.prototype.createContext = function() { | |||
| 663 | 658 | Object.defineProperty(context, 'console', { | |
| 664 | 659 | configurable: true, | |
| 665 | 660 | enumerable: true, | |
| 666 | - get: () => _console | ||
| 661 | + value: _console | ||
| 667 | 662 | }); | |
| 668 | 663 | ||
| 669 | 664 | var names = Object.getOwnPropertyNames(global); | |
@@ -1035,19 +1030,16 @@ function complete(line, callback) { | |||
| 1035 | 1030 | break; | |
| 1036 | 1031 | } | |
| 1037 | 1032 | } | |
| 1038 | - } catch (e) { | ||
| 1039 | - // console.log("completion error walking prototype chain:" + e); | ||
| 1040 | - } | ||
| 1033 | + } catch (e) {} | ||
| 1041 | 1034 | } | |
| 1042 | 1035 | ||
| 1043 | 1036 | if (memberGroups.length) { | |
| 1044 | 1037 | for (i = 0; i < memberGroups.length; i++) { | |
| 1045 | - completionGroups.push(memberGroups[i].map(function(member) { | ||
| 1046 | - return expr + '.' + member; | ||
| 1047 | - })); | ||
| 1038 | + completionGroups.push( | ||
| 1039 | + memberGroups[i].map((member) => `${expr}.${member}`)); | ||
| 1048 | 1040 | } | |
| 1049 | 1041 | if (filter) { | |
| 1050 | - filter = expr + '.' + filter; | ||
| 1042 | + filter = `${expr}.${filter}`; | ||
| 1051 | 1043 | } | |
| 1052 | 1044 | } | |
| 1053 | 1045 | ||
@@ -1068,9 +1060,8 @@ function complete(line, callback) { | |||
| 1068 | 1060 | if (completionGroups.length && filter) { | |
| 1069 | 1061 | var newCompletionGroups = []; | |
| 1070 | 1062 | for (i = 0; i < completionGroups.length; i++) { | |
| 1071 | - group = completionGroups[i].filter(function(elem) { | ||
| 1072 | - return elem.indexOf(filter) === 0; | ||
| 1073 | - }); | ||
| 1063 | + group = completionGroups[i] | ||
| 1064 | + .filter((elem) => elem.indexOf(filter) === 0); | ||
| 1074 | 1065 | if (group.length) { | |
| 1075 | 1066 | newCompletionGroups.push(group); | |
| 1076 | 1067 | } | |
@@ -1400,55 +1391,33 @@ function isCodeRecoverable(code) { | |||
| 1400 | 1391 | ||
| 1401 | 1392 | if (previous === '\\' && (stringLiteral || isRegExpLiteral)) { | |
| 1402 | 1393 | current = null; | |
| 1403 | - continue; | ||
| 1404 | - } | ||
| 1405 | - | ||
| 1406 | - if (stringLiteral) { | ||
| 1394 | + } else if (stringLiteral) { | ||
| 1407 | 1395 | if (stringLiteral === current) { | |
| 1408 | 1396 | stringLiteral = null; | |
| 1409 | 1397 | } | |
| 1410 | - continue; | ||
| 1411 | - } else { | ||
| 1412 | - if (isRegExpLiteral && current === '/') { | ||
| 1413 | - isRegExpLiteral = false; | ||
| 1414 | - continue; | ||
| 1415 | - } | ||
| 1416 | - | ||
| 1417 | - if (isBlockComment && previous === '*' && current === '/') { | ||
| 1418 | - isBlockComment = false; | ||
| 1419 | - continue; | ||
| 1420 | - } | ||
| 1421 | - | ||
| 1422 | - if (isSingleComment && current === '\n') { | ||
| 1423 | - isSingleComment = false; | ||
| 1424 | - continue; | ||
| 1425 | - } | ||
| 1426 | - | ||
| 1427 | - if (isBlockComment || isRegExpLiteral || isSingleComment) continue; | ||
| 1428 | - | ||
| 1398 | + } else if (isRegExpLiteral && current === '/') { | ||
| 1399 | + isRegExpLiteral = false; | ||
| 1400 | + } else if (isBlockComment && previous === '*' && current === '/') { | ||
| 1401 | + isBlockComment = false; | ||
| 1402 | + } else if (isSingleComment && current === '\n') { | ||
| 1403 | + isSingleComment = false; | ||
| 1404 | + } else if (!isBlockComment && !isRegExpLiteral && !isSingleComment) { | ||
| 1429 | 1405 | if (current === '/' && previous === '/') { | |
| 1430 | 1406 | isSingleComment = true; | |
| 1431 | - continue; | ||
| 1432 | - } | ||
| 1433 | - | ||
| 1434 | - if (previous === '/') { | ||
| 1407 | + } else if (previous === '/') { | ||
| 1435 | 1408 | if (current === '*') { | |
| 1436 | 1409 | isBlockComment = true; | |
| 1437 | - } else if ( | ||
| 1438 | 1410 | // Distinguish between a division operator and the start of a regex | |
| 1439 | 1411 | // by examining the non-whitespace character that precedes the / | |
| 1440 | - [null, '(', '[', '{', '}', ';'].includes(prevTokenChar) | ||
| 1441 | - ) { | ||
| 1412 | + } else if ([null, '(', '[', '{', '}', ';'].includes(prevTokenChar)) { | ||
| 1442 | 1413 | isRegExpLiteral = true; | |
| 1443 | 1414 | } | |
| 1444 | - continue; | ||
| 1415 | + } else { | ||
| 1416 | + if (current.trim()) prevTokenChar = current; | ||
| 1417 | + if (current === '\'' || current === '"') { | ||
| 1418 | + stringLiteral = current; | ||
| 1419 | + } | ||
| 1445 | 1420 | } | |
| 1446 | - | ||
| 1447 | - if (current.trim()) prevTokenChar = current; | ||
| 1448 | - } | ||
| 1449 | - | ||
| 1450 | - if (current === '\'' || current === '"') { | ||
| 1451 | - stringLiteral = current; | ||
| 1452 | 1421 | } | |
| 1453 | 1422 | } | |
| 1454 | 1423 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments