@@ -18,26 +18,26 @@ according to a user-defined evaluation function, then output the result. Input
18
18
and output may be from ` stdin ` and ` stdout ` , respectively, or may be connected
19
19
to any Node.js [ stream] [ ] .
20
20
21
- Instances of ` repl.REPLServer ` support persistent history of prior inputs,
22
- automatic completion of inputs, simplistic Emacs-style line editing, multi-line
23
- inputs, ANSI-styled output, saving and restoring current REPL session state,
24
- error recovery, and customizable evaluation functions.
21
+ Instances of ` repl.REPLServer ` support automatic completion of inputs,
22
+ simplistic Emacs-style line editing, multi-line inputs, ANSI-styled output,
23
+ saving and restoring current REPL session state, error recovery, and
24
+ customizable evaluation functions.
25
25
26
26
### Commands and Special Keys
27
27
28
28
The following special commands are supported by all REPL instances:
29
29
30
30
* ` .break ` - When in the process of inputting a multi-line expression, entering
31
- the ` .break ` command (or pressing the ` <Ctrl >-C ` key combination) will abort
31
+ the ` .break ` command (or pressing the ` <ctrl >-C ` key combination) will abort
32
32
further input or processing of that expression.
33
33
* ` .clear ` - Resets the REPL ` context ` to an empty object and clears any
34
34
multi-line expression currently being input.
35
35
* ` .exit ` - Close the I/O stream, causing the REPL to exit.
36
36
* ` .help ` - Show this list of special commands.
37
37
* ` .save ` - Save the current REPL session to a file:
38
- ` >.save ./file/to/save.js `
38
+ ` > .save ./file/to/save.js `
39
39
* ` .load ` - Load a file into the current REPL session.
40
- ` >.load ./file/to/load.js `
40
+ ` > .load ./file/to/load.js `
41
41
42
42
The following key combinations in the REPL have these special effects:
43
43
@@ -60,11 +60,11 @@ evaluation function when the `repl.REPLServer` instance is created.
60
60
61
61
The default evaluator supports direct evaluation of JavaScript expressions:
62
62
63
- ```
63
+ ``` js
64
64
> 1 + 1
65
65
2
66
66
> var m = 2
67
- 1
67
+ undefined
68
68
> m + 1
69
69
3
70
70
```
@@ -88,7 +88,7 @@ repl.start('> ').context.m = msg;
88
88
89
89
Properties in the ` context ` object appear as local within the REPL:
90
90
91
- ```
91
+ ``` js
92
92
$ node repl_test .js
93
93
> m
94
94
' message'
@@ -117,7 +117,7 @@ REPL environment when used. For instance, unless otherwise declared as a
117
117
global or scoped variable, the input ` fs ` will be evaluated on-demand as
118
118
` global.fs = require('fs') ` .
119
119
120
- ```
120
+ ``` js
121
121
> fs .createReadStream (' ./some/file' );
122
122
```
123
123
@@ -126,7 +126,7 @@ global or scoped variable, the input `fs` will be evaluated on-demand as
126
126
The default evaluator will, by default, assign the result of the most recently
127
127
evaluated expression to the special variable ` _ ` (underscore).
128
128
129
- ```
129
+ ``` js
130
130
> [ ' a' , ' b' , ' c' ]
131
131
[ ' a' , ' b' , ' c' ]
132
132
> _ .length
@@ -215,16 +215,16 @@ function myWriter(output) {
215
215
216
216
## Class: REPLServer
217
217
218
- The ` repl.REPLServer ` class inherits from the [ ` readline.Interface ` ] [ ] class.
218
+ The ` repl.REPLServer ` class inherits from the [ ` readline.Interface ` ] [ ] class.
219
219
Instances of ` repl.REPLServer ` are created using the ` repl.start() ` method and
220
220
* should not* be created directly using the JavaScript ` new ` keyword.
221
221
222
222
### Event: 'exit'
223
223
224
- The ` 'exit' ` event is emitted the REPL is exited either by receiving the ` .exit `
225
- command as input, the user pressing ` <Ctrl >-C ` twice to signal ` SIGINT ` , or by
226
- presing ` <Ctrl >-D` to signal ` 'end' ` on the input stream. The listener callback
227
- is invoked without any arguments.
224
+ The ` 'exit' ` event is emitted when the REPL is exited either by receiving the
225
+ ` .exit ` command as input, the user pressing ` <ctrl >-C ` twice to signal ` SIGINT ` ,
226
+ or by pressing ` <ctrl >-D` to signal ` 'end' ` on the input stream. The listener
227
+ callback is invoked without any arguments.
228
228
229
229
``` js
230
230
replServer .on (' exit' , () => {
@@ -260,7 +260,7 @@ r.on('reset', initializeContext);
260
260
When this code is executed, the global ` 'm' ` variable can be modified but then
261
261
reset to its initial value using the ` .clear ` command:
262
262
263
- ```
263
+ ``` js
264
264
$ ./ node example .js
265
265
> m
266
266
' test'
@@ -327,7 +327,7 @@ The `replServer.displayPrompt()` method readies the REPL instance for input
327
327
from the user, printing the configured ` prompt ` to a new line in the ` output `
328
328
and resuming the ` input ` to accept new input.
329
329
330
- When multi-line input is being entered, an ellipsis is printed rather the the
330
+ When multi-line input is being entered, an ellipsis is printed rather than the
331
331
'prompt'.
332
332
333
333
When ` preserveCusor ` is ` true ` , the cursor placement will not be reset to ` 0 ` .
@@ -381,9 +381,8 @@ Node.js itself uses the `repl` module to provide its own interactive interface
381
381
for executing JavaScript. This can used by executing the Node.js binary without
382
382
passing any arguments (or by passing the ` -i ` argument):
383
383
384
- ```
384
+ ``` js
385
385
$ node
386
- Type '.help' for options.
387
386
> a = [1 , 2 , 3 ];
388
387
[ 1 , 2 , 3 ]
389
388
> a .forEach ((v ) => {
@@ -436,7 +435,7 @@ terminal settings which will allow you to use with `rlwrap`.
436
435
437
436
For example, you could add this to your bashrc file:
438
437
439
- ```
438
+ ``` text
440
439
alias node="env NODE_NO_READLINE=1 rlwrap node"
441
440
```
442
441
0 commit comments