Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: code style cleanups in repl.markdown
per: nodejs/node-v0.x-archive#8778

originally submitted by @reggi
  • Loading branch information
jasnell committed Aug 26, 2015
commit 81e4274136eedaac69fbe8810c2b76cfda607914
25 changes: 12 additions & 13 deletions doc/api/repl.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -117,32 +117,31 @@ will share the same global object but will have unique I/O.

Here is an example that starts a REPL on stdin, a Unix socket, and a TCP socket:

var net = require("net"),
repl = require("repl");

connections = 0;
var net = require('net'),
repl = require('repl'),
connections = 0;

repl.start({
prompt: "Node.js via stdin> ",
prompt: 'Node.js via stdin> ',
input: process.stdin,
output: process.stdout
});

net.createServer(function (socket) {
connections += 1;
repl.start({
prompt: "Node.js via Unix socket> ",
prompt: 'Node.js via Unix socket> ',
input: socket,
output: socket
}).on('exit', function() {
socket.end();
})
}).listen("/tmp/node-repl-sock");
}).listen('/tmp/node-repl-sock');

net.createServer(function (socket) {
connections += 1;
repl.start({
prompt: "Node.js via TCP socket> ",
prompt: 'Node.js via TCP socket> ',
input: socket,
output: socket
}).on('exit', function() {
Expand Down Expand Up @@ -191,7 +190,7 @@ be emitted.
Example of listening for `reset`:

// Extend the initial repl context.
r = repl.start({ options ... });
var r = repl.start({ options ... });
someExtension.extend(r.context);

// When a new context is created extend it as well.
Expand All @@ -213,7 +212,7 @@ accessing `fs` will `require()` the `fs` module as `global.fs`.

The special variable `_` (underscore) contains the result of the last expression.

> [ "a", "b", "c" ]
> [ 'a', 'b', 'c' ]
[ 'a', 'b', 'c' ]
> _.length
3
Expand All @@ -225,10 +224,10 @@ a variable to the REPL explicitly by assigning it to the `context` object
associated with each `REPLServer`. For example:

// repl_test.js
var repl = require("repl"),
msg = "message";
var repl = require('repl'),
msg = 'message';

repl.start("> ").context.m = msg;
repl.start('> ').context.m = msg;

Things in the `context` object appear as local within the REPL:

Expand Down