@@ -117,32 +117,31 @@ will share the same global object but will have unique I/O.
117
117
118
118
Here is an example that starts a REPL on stdin, a Unix socket, and a TCP socket:
119
119
120
- var net = require("net"),
121
- repl = require("repl");
122
-
123
- connections = 0;
120
+ var net = require('net'),
121
+ repl = require('repl'),
122
+ connections = 0;
124
123
125
124
repl.start({
126
- prompt: " Node.js via stdin> " ,
125
+ prompt: ' Node.js via stdin> ' ,
127
126
input: process.stdin,
128
127
output: process.stdout
129
128
});
130
129
131
130
net.createServer(function (socket) {
132
131
connections += 1;
133
132
repl.start({
134
- prompt: " Node.js via Unix socket> " ,
133
+ prompt: ' Node.js via Unix socket> ' ,
135
134
input: socket,
136
135
output: socket
137
136
}).on('exit', function() {
138
137
socket.end();
139
138
})
140
- }).listen(" /tmp/node-repl-sock" );
139
+ }).listen(' /tmp/node-repl-sock' );
141
140
142
141
net.createServer(function (socket) {
143
142
connections += 1;
144
143
repl.start({
145
- prompt: " Node.js via TCP socket> " ,
144
+ prompt: ' Node.js via TCP socket> ' ,
146
145
input: socket,
147
146
output: socket
148
147
}).on('exit', function() {
@@ -191,7 +190,7 @@ be emitted.
191
190
Example of listening for ` reset ` :
192
191
193
192
// Extend the initial repl context.
194
- r = repl.start({ options ... });
193
+ var r = repl.start({ options ... });
195
194
someExtension.extend(r.context);
196
195
197
196
// When a new context is created extend it as well.
@@ -213,7 +212,7 @@ accessing `fs` will `require()` the `fs` module as `global.fs`.
213
212
214
213
The special variable ` _ ` (underscore) contains the result of the last expression.
215
214
216
- > [ "a", "b", "c" ]
215
+ > [ 'a', 'b', 'c' ]
217
216
[ 'a', 'b', 'c' ]
218
217
> _.length
219
218
3
@@ -225,10 +224,10 @@ a variable to the REPL explicitly by assigning it to the `context` object
225
224
associated with each ` REPLServer ` . For example:
226
225
227
226
// repl_test.js
228
- var repl = require(" repl" ),
229
- msg = " message" ;
227
+ var repl = require(' repl' ),
228
+ msg = ' message' ;
230
229
231
- repl.start("> " ).context.m = msg;
230
+ repl.start('> ' ).context.m = msg;
232
231
233
232
Things in the ` context ` object appear as local within the REPL:
234
233
0 commit comments