Skip to content

Commit 2c85dd9

Browse files
BridgeARBethGriggs
authored andcommitted
doc: update REPL documentation to instantiate the REPL
The documentation currently states that it's not intended to directly instantiate REPL instances. It is unknown for what reason that's recommended as it does seem a proper way to handle new REPL instances. PR-URL: #30928 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 2501982 commit 2c85dd9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

doc/api/repl.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,20 @@ function myWriter(output) {
332332
added: v0.1.91
333333
-->
334334

335+
* `options` {Object|string} See [`repl.start()`][]
335336
* Extends: {readline.Interface}
336337

337-
Instances of `repl.REPLServer` are created using the `repl.start()` method and
338-
*should not* be created directly using the JavaScript `new` keyword.
338+
Instances of `repl.REPLServer` are created using the [`repl.start()`][] method
339+
or directly using the JavaScript `new` keyword.
340+
341+
```js
342+
const repl = require('repl');
343+
344+
const options = { useColors: true };
345+
346+
const firstInstance = repl.start(options);
347+
const secondInstance = new repl.REPLServer(options);
348+
```
339349

340350
### Event: `'exit'`
341351
<!-- YAML
@@ -697,6 +707,7 @@ For an example of running a REPL instance over [curl(1)][], see:
697707
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn
698708
[`readline.InterfaceCompleter`]: readline.html#readline_use_of_the_completer_function
699709
[`repl.ReplServer`]: #repl_class_replserver
710+
[`repl.start()`]: #repl_repl_start_options
700711
[`util.inspect()`]: util.html#util_util_inspect_object_options
701712
[curl(1)]: https://curl.haxx.se/docs/manpage.html
702713
[stream]: stream.html

0 commit comments

Comments
 (0)