class REPLServer extends Object with StObject
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 from stdin and stdout, respectively, or may be connected to any Node.js stream.
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 the repl.start() method and _should not_
be created directly using the JavaScript new keyword.
- Annotations
- @JSType() @JSImport("repl", "REPLServer") @native()
- Source
- replMod.scala
- See also
https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_repl
- Alphabetic
- By Inheritance
- REPLServer
- StObject
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new REPLServer()
- Attributes
- protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def addListener(event: java.lang.String, listener: Function1[Any, Unit]): REPLServer.this.type
events.EventEmitter 1.
events.EventEmitter 1. close - inherited from
readline.Interface2. line - inherited fromreadline.Interface3. pause - inherited fromreadline.Interface4. resume - inherited fromreadline.Interface5. SIGCONT - inherited fromreadline.Interface6. SIGINT - inherited fromreadline.Interface7. SIGTSTP - inherited fromreadline.Interface8. exit 9. reset - def addListener_SIGCONT(event: SIGCONT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- def addListener_SIGINT(event: SIGINT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- def addListener_SIGTSTP(event: SIGTSTP, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- def addListener_close(event: close, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- def addListener_exit(event: exit, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- def addListener_line(event: line, listener: Function1[java.lang.String, Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- def addListener_pause(event: pause, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- def addListener_reset(event: reset, listener: Function1[Context, Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- def addListener_resume(event: resume, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("addListener")
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clearBufferedCommand(): Unit
Clears any command that has been buffered but not yet executed.
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.- Since
v9.0.0
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- val commands: ReadOnlyDict[REPLCommand]
The commands registered via
replServer.defineCommand(). - val completer: |[Completer, AsyncCompleter]
Specified in the REPL options, this is the function to use for custom Tab auto-completion.
- val context: Context
The
vm.Contextprovided to theevalfunction to be used for JavaScript evaluation. - def defineCommand(keyword: java.lang.String, cmd: REPLCommandAction): Unit
Used to add new
.-prefixed commands to the REPL instance.Used to add new
.-prefixed commands to the REPL instance. Such commands are invoked by typing a.followed by thekeyword.- keyword
The command keyword (_without_ a leading
.character).- cmd
The function to invoke when the command is processed.
- See also
https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_replserver_definecommand_keyword_cmd
- def defineCommand(keyword: java.lang.String, cmd: REPLCommand): Unit
- def displayPrompt(preserveCursor: Boolean): Unit
- def displayPrompt(): Unit
Readies the REPL instance for input from the user, printing the configured
promptto a new line in theoutputand resuming theinputto accept new input.Readies the REPL instance for input from the user, printing the configured
promptto a new line in theoutputand resuming theinputto 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. - val editorMode: Boolean
A value indicating whether the REPL is currently in "editor mode".
A value indicating whether the REPL is currently in "editor mode".
- See also
https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_commands_and_special_keys
- def emit(event: Symbol, args: Any*): Boolean
- def emit(event: java.lang.String, args: Any*): Boolean
- def emit_SIGCONT(event: SIGCONT): Boolean
- Annotations
- @JSName("emit")
- def emit_SIGINT(event: SIGINT): Boolean
- Annotations
- @JSName("emit")
- def emit_SIGTSTP(event: SIGTSTP): Boolean
- Annotations
- @JSName("emit")
- def emit_close(event: close): Boolean
- Annotations
- @JSName("emit")
- def emit_exit(event: exit): Boolean
- Annotations
- @JSName("emit")
- def emit_line(event: line, input: java.lang.String): Boolean
- Annotations
- @JSName("emit")
- def emit_pause(event: pause): Boolean
- Annotations
- @JSName("emit")
- def emit_reset(event: reset, context: Context): Boolean
- Annotations
- @JSName("emit")
- def emit_resume(event: resume): Boolean
- Annotations
- @JSName("emit")
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def eval(evalCmd: java.lang.String, context: Context, file: java.lang.String, cb: Function2[|[Error, Null], Any, Unit]): Unit
Specified in the REPL options, this is the function to be used when evaluating each given line of input.
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. - final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hasOwnProperty(v: scala.Predef.String): Boolean
- Definition Classes
- Object
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- val ignoreUndefined: Boolean
Specified in the REPL options, this is a value indicating whether the default
writerfunction should output the result of a command if it evaluates toundefined. - val input: ReadableStream
The
Readablestream from which REPL input will be read. - final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
- val last: Any
The last evaluation result from the REPL (assigned to the
_variable inside of the REPL).The last evaluation result from the REPL (assigned to the
_variable inside of the REPL).- See also
https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
- val lastError: Any
The last error raised inside the REPL (assigned to the
_errorvariable inside of the REPL).The last error raised inside the REPL (assigned to the
_errorvariable inside of the REPL).- Since
v9.8.0
- See also
https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def on(event: java.lang.String, listener: Function1[Any, Unit]): REPLServer.this.type
- def on_SIGCONT(event: SIGCONT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def on_SIGINT(event: SIGINT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def on_SIGTSTP(event: SIGTSTP, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def on_close(event: close, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def on_exit(event: exit, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def on_line(event: line, listener: Function1[java.lang.String, Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def on_pause(event: pause, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def on_reset(event: reset, listener: Function1[Context, Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def on_resume(event: resume, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("on")
- def once(event: java.lang.String, listener: Function1[Any, Unit]): REPLServer.this.type
- def once_SIGCONT(event: SIGCONT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- def once_SIGINT(event: SIGINT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- def once_SIGTSTP(event: SIGTSTP, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- def once_close(event: close, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- def once_exit(event: exit, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- def once_line(event: line, listener: Function1[java.lang.String, Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- def once_pause(event: pause, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- def once_reset(event: reset, listener: Function1[Context, Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- def once_resume(event: resume, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("once")
- val output: WritableStream
The
Writablestream to which REPL output will be written. - def prependListener(event: java.lang.String, listener: Function1[Any, Unit]): REPLServer.this.type
- def prependListener_SIGCONT(event: SIGCONT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependListener_SIGINT(event: SIGINT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependListener_SIGTSTP(event: SIGTSTP, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependListener_close(event: close, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependListener_exit(event: exit, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependListener_line(event: line, listener: Function1[java.lang.String, Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependListener_pause(event: pause, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependListener_reset(event: reset, listener: Function1[Context, Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependListener_resume(event: resume, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependListener")
- def prependOnceListener(event: java.lang.String, listener: Function1[Any, Unit]): REPLServer.this.type
- def prependOnceListener_SIGCONT(event: SIGCONT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def prependOnceListener_SIGINT(event: SIGINT, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def prependOnceListener_SIGTSTP(event: SIGTSTP, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def prependOnceListener_close(event: close, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def prependOnceListener_exit(event: exit, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def prependOnceListener_line(event: line, listener: Function1[java.lang.String, Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def prependOnceListener_pause(event: pause, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def prependOnceListener_reset(event: reset, listener: Function1[Context, Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def prependOnceListener_resume(event: resume, listener: Function0[Unit]): REPLServer.this.type
- Annotations
- @JSName("prependOnceListener")
- def propertyIsEnumerable(v: scala.Predef.String): Boolean
- Definition Classes
- Object
- val replMode: Symbol
Specified in the REPL options, this is a flag that specifies whether the default
evalfunction should execute all JavaScript commands in strict mode or default (sloppy) mode.Specified in the REPL options, this is a flag that specifies whether the default
evalfunction 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'. - def setupHistory(path: java.lang.String, cb: Function2[|[Error, Null], REPLServer.this.type, Unit]): Unit
Initializes a history log file for the REPL instance.
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.
- path
The path to the history file
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toLocaleString(): scala.Predef.String
- Definition Classes
- Object
- def toString(): java.lang.String
- Definition Classes
- AnyRef → Any
- val underscoreAssigned: Boolean
A value indicating whether the
_variable has been assigned.A value indicating whether the
_variable has been assigned.- See also
https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
- val underscoreErrAssigned: Boolean
A value indicating whether the
_errorvariable has been assigned.A value indicating whether the
_errorvariable has been assigned.- Since
v9.8.0
- See also
https://nodejs.org/dist/latest-v10.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
- val useColors: Boolean
Specified in the REPL options, this is a value indicating whether the default
writerfunction should include ANSI color styling to REPL output. - val useGlobal: Boolean
Specified in the REPL options, this is a value indicating whether the default
evalfunction will use the JavaScriptglobalas the context as opposed to creating a new separate context for the REPL instance. - def valueOf(): Any
- Definition Classes
- Object
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def writer(obj: Any): java.lang.String
Specified in the REPL options, this is the function to invoke to format the output of each command before writing to
outputStream.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 forutil.inspect.
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
- val inputStream: ReadableStream
- Deprecated
since v14.3.0 - Use
inputinstead.
- val outputStream: WritableStream
- Deprecated
since v14.3.0 - Use
outputinstead.