|
|
@ -10,9 +10,9 @@ dropped into the REPL. It has simplistic emacs line-editing. |
|
|
|
|
|
|
|
mjr:~$ node |
|
|
|
Type '.help' for options. |
|
|
|
node> a = [ 1, 2, 3]; |
|
|
|
> a = [ 1, 2, 3]; |
|
|
|
[ 1, 2, 3 ] |
|
|
|
node> a.forEach(function (v) { |
|
|
|
> a.forEach(function (v) { |
|
|
|
... console.log(v); |
|
|
|
... }); |
|
|
|
1 |
|
|
@ -27,10 +27,10 @@ For example, you could add this to your bashrc file: |
|
|
|
alias node="env NODE_NO_READLINE=1 rlwrap node" |
|
|
|
|
|
|
|
|
|
|
|
### repl.start(prompt='node> ', stream=process.openStdin()) |
|
|
|
### repl.start(prompt='> ', stream=process.openStdin()) |
|
|
|
|
|
|
|
Starts a REPL with `prompt` as the prompt and `stream` for all I/O. `prompt` |
|
|
|
is optional and defaults to `node> `. `stream` is optional and defaults to |
|
|
|
is optional and defaults to `> `. `stream` is optional and defaults to |
|
|
|
`process.openStdin()`. |
|
|
|
|
|
|
|
Multiple REPLs may be started against the same running instance of node. Each |
|
|
@ -70,11 +70,11 @@ Inside the REPL, Control+D will exit. Multi-line expressions can be input. |
|
|
|
|
|
|
|
The special variable `_` (underscore) contains the result of the last expression. |
|
|
|
|
|
|
|
node> [ "a", "b", "c" ] |
|
|
|
> [ "a", "b", "c" ] |
|
|
|
[ 'a', 'b', 'c' ] |
|
|
|
node> _.length |
|
|
|
> _.length |
|
|
|
3 |
|
|
|
node> _ += 1 |
|
|
|
> _ += 1 |
|
|
|
4 |
|
|
|
|
|
|
|
The REPL provides access to any variables in the global scope. You can expose a variable |
|
|
@ -90,7 +90,7 @@ to the REPL explicitly by assigning it to the `context` object associated with e |
|
|
|
Things in the `context` object appear as local within the REPL: |
|
|
|
|
|
|
|
mjr:~$ node repl_test.js |
|
|
|
node> m |
|
|
|
> m |
|
|
|
'message' |
|
|
|
|
|
|
|
There are a few special REPL commands: |
|
|
|