Stop evaluating the current piece of code when SIGINT is received, i.e. Ctrl+C is pressed. This cannot be used together with a custom eval function.
interface
repl.ReplOptions
interface ReplOptions
- breakEvalOnSigint?: boolean
- eval?: REPLEval
The function to be used when evaluating each given line of input. Default: an async wrapper for the JavaScript
eval()function. Anevalfunction can error withrepl.Recoverableto indicate the input was incomplete and prompt for additional lines. See the custom evaluation functions section for more details. - handleError?: (err: unknown) => 'ignore' | 'print' | 'unhandled'
This function customizes error handling in the REPL. It receives the thrown exception as its first argument and must return one of the following values synchronously:
'print'to print the error to the output stream (default behavior).'ignore'to skip all remaining error handling.'unhandled'to treat the exception as fully unhandled. In this case, the error will be passed to process-wide exception handlers, such as the'uncaughtException'event. The'unhandled'value may or may not be desirable in situations where theREPLServerinstance has been closed, depending on the particular use case.
- ignoreUndefined?: boolean
If
true, specifies that the default writer will not output the return value of a command if it evaluates toundefined. - replMode?: typeof REPL_MODE_SLOPPY | typeof REPL_MODE_STRICT
A flag that specifies whether the default evaluator executes all JavaScript commands in strict mode or default (sloppy) mode. Accepted values are:
repl.REPL_MODE_SLOPPY- evaluates expressions in sloppy mode.repl.REPL_MODE_STRICT- evaluates expressions in strict mode. This is equivalent to prefacing every repl statement with'use strict'.
- terminal?: boolean
If
true, specifies that the output should be treated as a TTY terminal, and have ANSI/VT100 escape codes written to it. Default: checking the value of theisTTYproperty on the output stream upon instantiation. - useColors?: boolean
If
true, specifies that the defaultwriterfunction should include ANSI color styling to REPL output. If a customwriterfunction is provided then this has no effect. - useGlobal?: boolean
If
true, specifies that the default evaluation function will use the JavaScriptglobalas the context as opposed to creating a new separate context for the REPL instance. The node CLI REPL sets this value totrue. - writer?: REPLWriter
The function to invoke to format the output of each command before writing to
output.