NOTE: According to the documentation:
Instances of
repl.REPLServer
are created using therepl.start()
method and should not be created directly using the JavaScriptnew
keyword.
REPLServer
cannot be subclassed due to implementation specifics in NodeJS.
The commands registered via replServer.defineCommand()
.
Specified in the REPL options, this is the function to use for custom Tab auto-completion.
The vm.Context
provided to the eval
function to be used for JavaScript
evaluation.
The current cursor position in the input line
A value indicating whether the REPL is currently in "editor mode".
Specified in the REPL options, this is the function to be used when evaluating each
given line of input. If not specified in the REPL options, this is an async wrapper
for the JavaScript eval()
function.
Specified in the REPL options, this is a value indicating whether the default writer
function should output the result of a command if it evaluates to undefined
.
The Readable
stream from which REPL input will be read.
The last evaluation result from the REPL (assigned to the _
variable inside of the REPL).
The last error raised inside the REPL (assigned to the _error
variable inside of the REPL).
The current input data
The Writable
stream to which REPL output will be written.
Specified in the REPL options, this is a flag that specifies whether the default eval
function should execute all JavaScript commands in strict mode or default (sloppy) mode.
Possible 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'
.A value indicating whether the _
variable has been assigned.
A value indicating whether the _error
variable has been assigned.
Specified in the REPL options, this is a value indicating whether the default
writer
function should include ANSI color styling to REPL output.
Specified in the REPL options, this is a value indicating whether the default eval
function will use the JavaScript global
as the context as opposed to creating a new
separate context for the REPL instance.
Specified in the REPL options, this is the function to invoke to format the output of
each command before writing to outputStream
. If not specified in the REPL options,
this will be a wrapper for util.inspect
.
events.EventEmitter
readline.Interface
readline.Interface
readline.Interface
readline.Interface
readline.Interface
readline.Interface
readline.Interface
Clears any command that has been buffered but not yet executed.
This method is primarily intended to be called from within the action function for
commands registered using the replServer.defineCommand()
method.
Used to add new .
-prefixed commands to the REPL instance. Such commands are invoked
by typing a .
followed by the keyword
.
The command keyword (without a leading .
character).
The function to invoke when the command is processed.
Readies the REPL instance for input from the user, printing the configured prompt
to a
new line in the output
and resuming the input
to accept new input.
When multi-line input is being entered, an ellipsis is printed rather than the 'prompt'.
This method is primarily intended to be called from within the action function for
commands registered using the replServer.defineCommand()
method.
When true
, the cursor placement will not be reset to 0
.
Returns the real position of the cursor in relation to the input prompt + string. Long input (wrapping) strings, as well as multiple line prompts are included in the calculations.
Initializes a history log file for the REPL instance. When executing the Node.js binary and using the command line REPL, a history file is initialized by default. However, this is not the case when creating a REPL programmatically. Use this method to initialize a history log file when working with REPL instances programmatically.
The path to the history file
Generated using TypeDoc
Provides a customizable Read-Eval-Print-Loop (REPL).
Instances of
repl.REPLServer
will accept individual lines of user input, evaluate those according to a user-defined evaluation function, then output the result. Input and output may be fromstdin
andstdout
, respectively, or may be connected to any Node.jsstream
.Instances of
repl.REPLServer
support automatic completion of inputs, simplistic Emacs-style line editing, multi-line inputs, ANSI-styled output, saving and restoring current REPL session state, error recovery, and customizable evaluation functions.Instances of
repl.REPLServer
are created using therepl.start()
method and should not be created directly using the JavaScriptnew
keyword.https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_repl