summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Rajlich <nathan@tootallnate.net>2012-10-05 18:33:28 -0700
committerNathan Rajlich <nathan@tootallnate.net>2012-10-05 18:33:28 -0700
commit59c166cfba380f108b45d4aab9ce61dcfdfff46a (patch)
tree5ada5a2fc351b87b1580f7fca892404fc97e413f
parentf826b3269d62cd64439d68a145eeeb658973740c (diff)
downloadnode-59c166cfba380f108b45d4aab9ce61dcfdfff46a.tar.gz
repl: move "isSyntaxError()" definition to the bottom
fixes lint "line length too long" error
-rw-r--r--lib/repl.js30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/repl.js b/lib/repl.js
index b10427a16..af0d422a4 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -267,18 +267,6 @@ function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
finish(null);
}
- function isSyntaxError(e) {
- // Convert error to string
- e = e && (e.stack || e.toString());
- return e && e.match(/^SyntaxError/) &&
- // RegExp syntax error
- !e.match(/^SyntaxError: Invalid regular expression/) &&
- !e.match(/^SyntaxError: Invalid flags supplied to RegExp constructor/) &&
- // JSON.parse() error
- !(e.match(/^SyntaxError: Unexpected (token .*|end of input)/) &&
- e.match(/\n at Object.parse \(native\)\n/));
- }
-
function finish(e, ret) {
self.memory(cmd);
@@ -918,3 +906,21 @@ REPLServer.prototype.convertToContext = function(cmd) {
return cmd;
};
+
+
+/**
+ * Returns `true` if "e" is a SyntaxError, `false` otherwise.
+ * This function filters out false positives likes JSON.parse() errors and
+ * RegExp syntax errors.
+ */
+function isSyntaxError(e) {
+ // Convert error to string
+ e = e && (e.stack || e.toString());
+ return e && e.match(/^SyntaxError/) &&
+ // RegExp syntax error
+ !e.match(/^SyntaxError: Invalid regular expression/) &&
+ !e.match(/^SyntaxError: Invalid flags supplied to RegExp constructor/) &&
+ // JSON.parse() error
+ !(e.match(/^SyntaxError: Unexpected (token .*|end of input)/) &&
+ e.match(/\n at Object.parse \(native\)\n/));
+}