What is REPL?
The REPL stand for “Read
Eval Print Loop” and The REPL module provides a “Read-Eval-Print-Loop”
implementation.
I.
Read – Read user inputs.
II.
Eval – Evaluates the data structure.
III.
Print – Print the result.
IV.
Loop - Loops the above command until the user multiple presses.
It is also
represents a computer environment likes,
I.
A Windows Console,
II.
UNIX and
III.
Linux etc.
In Node.js,
The REPL is use for JavaScript code debugging and also
for experimenting etc.
It is also available
for standalone or other accessible programs.
Node.js itself
uses the REPL module to provide its own interactive interface
for executing JavaScript and it can use by executing the Node.js binary without
passing any arguments.
It is using
looks like, const repl = require
('repl');
The REPL module exports from the “repl.REPLServer” class
and the Instances of “repl.REPLServer” is automatically supported to,
I.
Completion of
inputs,
II.
Simplistic
Emacs style line editing,
III.
Multi line
inputs and
IV.
ANSI styled
output etc.
By default,
all instances of “repl.REPLServer” are using an evaluation function that are evaluates
JavaScript expressions and provides access to “Node.js” built in modules.
The special keys
and commands are supported by REPL,
I.
.break
– This command is use to exit from multiline expressions.
II.
.clear
– This command is use to reset the REPL
context.
III.
.exit
– This command is use to close the I/O stream.
IV.
.help
– This command is use to display the list of special commands.
V.
.save
– This command is use to save the current REPL
session.
VI.
.load
– This command is use to load a file into the current REPL session.
VII.
.editor
- This command is use to allow editor mode.
VIII.
Ctrl
+ c
− This command is use to terminate the current command.
IX.
Ctrl
+ c twice − This command is use to terminate the Node REPL.
X.
Ctrl
+ d
− terminate the Node REPL.
I hope this information will be helpful! Thank
you!