Skip to content

Commit cc44325

Browse files
BridgeARtargos
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 <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ca23511 commit cc44325

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
@@ -352,10 +352,20 @@ function myWriter(output) {
352352
added: v0.1.91
353353
-->
354354

355+
* `options` {Object|string} See [`repl.start()`][]
355356
* Extends: {readline.Interface}
356357

357-
Instances of `repl.REPLServer` are created using the `repl.start()` method and
358-
*should not* be created directly using the JavaScript `new` keyword.
358+
Instances of `repl.REPLServer` are created using the [`repl.start()`][] method
359+
or directly using the JavaScript `new` keyword.
360+
361+
```js
362+
const repl = require('repl');
363+
364+
const options = { useColors: true };
365+
366+
const firstInstance = repl.start(options);
367+
const secondInstance = new repl.REPLServer(options);
368+
```
359369

360370
### Event: `'exit'`
361371
<!-- YAML
@@ -724,6 +734,7 @@ For an example of running a REPL instance over [curl(1)][], see:
724734
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn
725735
[`readline.InterfaceCompleter`]: readline.html#readline_use_of_the_completer_function
726736
[`repl.ReplServer`]: #repl_class_replserver
737+
[`repl.start()`]: #repl_repl_start_options
727738
[`util.inspect()`]: util.html#util_util_inspect_object_options
728739
[curl(1)]: https://curl.haxx.se/docs/manpage.html
729740
[stream]: stream.html

0 commit comments

Comments
 (0)