alias node-repl="rlwrap node-repl"+
diff --git a/bin/node-repl b/bin/node-repl index ae5ca9d6fe..20f04e89fc 100755 --- a/bin/node-repl +++ b/bin/node-repl @@ -6,6 +6,6 @@ puts("Enter ECMAScript at the prompt."); puts("Tip 1: Use 'rlwrap node-repl' for a better interface"); puts("Tip 2: Type Control-D to exit."); -include("/repl.js"); +require("/repl.js").start(); // vim:ft=javascript diff --git a/doc/api.html b/doc/api.html index 80feec48d7..fe985109fa 100644 --- a/doc/api.html +++ b/doc/api.html @@ -1866,6 +1866,34 @@ on error: returns code, msg. code is one of the error codes li +
A Read-Eval-Print-Loop is available both as a standalone program and easily +includable in other programs.
The standalone REPL is called node-repl and is installed at +$PREFIX/bin/node-repl. It’s recommended to use it with the program +rlwrap for a better user interface. I set
alias node-repl="rlwrap node-repl"+
in my zsh configuration.
Inside the REPL, Control+D will exit. The special variable _ (underscore) contains the +result of the last expression.
The library is called /repl.js and it can be used like this:
include("/utils.js"); +include("/tcp.js"); +nconnections = 0; +createServer(function (c) { + error("Connection!"); + nconnections += 1; + c.close(); +}).listen(5000); +require("/repl.js").start("simple tcp server> ");+
External modules can be compiled and dynamically linked into Node. @@ -1955,7 +1983,7 @@ init (Handle<Object> target)