summaryrefslogtreecommitdiff
path: root/doc/api/repl.md
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-01-19 15:34:00 +0100
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-03-08 04:44:56 +0100
commit82f882140120f4ce074fe0de01e380cb3c7c9fc3 (patch)
tree0ac564d4e68c0564b0d185b1e2c7ad5b2eb77543 /doc/api/repl.md
parent6de88015bbeb9cd9c6442399db6e8838abd8bec2 (diff)
downloadandroid-node-v8-82f882140120f4ce074fe0de01e380cb3c7c9fc3.tar.gz
android-node-v8-82f882140120f4ce074fe0de01e380cb3c7c9fc3.tar.bz2
android-node-v8-82f882140120f4ce074fe0de01e380cb3c7c9fc3.zip
repl: add replDefaults to customize the writer
So far it was not possible to modify the inspection defaults used by the REPL from the running instance itself. This introduces a new property on `util.inspect` which is only used inside the REPL and which allows to modify the used inspection defaults at any point of time. PR-URL: https://github.com/nodejs/node/pull/26375 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/repl.md')
-rw-r--r--doc/api/repl.md31
1 files changed, 25 insertions, 6 deletions
diff --git a/doc/api/repl.md b/doc/api/repl.md
index 324b15f385..4ea2e8c906 100644
--- a/doc/api/repl.md
+++ b/doc/api/repl.md
@@ -256,13 +256,32 @@ function isRecoverableError(error) {
By default, [`repl.REPLServer`][] instances format output using the
[`util.inspect()`][] method before writing the output to the provided `Writable`
-stream (`process.stdout` by default). The `useColors` boolean option can be
-specified at construction to instruct the default writer to use ANSI style
-codes to colorize the output from the `util.inspect()` method.
+stream (`process.stdout` by default). The `showProxy` inspection option is set
+to true by default and the `colors` option is set to true depending on the
+REPL's `useColors` option.
-It is possible to fully customize the output of a [`repl.REPLServer`][] instance
-by passing a new function in using the `writer` option on construction. The
-following example, for instance, simply converts any input text to upper case:
+The `useColors` boolean option can be specified at construction to instruct the
+default writer to use ANSI style codes to colorize the output from the
+`util.inspect()` method.
+
+If the REPL is run as standalone program, it is also possible to change the
+REPL's [inspection defaults][`util.inspect()`] from inside the REPL by using the
+`inspect.replDefaults` property which mirrors the `defaultOptions` from
+[`util.inspect()`][].
+
+```console
+> util.inspect.replDefaults.compact = false;
+false
+> [1]
+[
+ 1
+]
+>
+```
+
+To fully customize the output of a [`repl.REPLServer`][] instance pass in a new
+function for the `writer` option on construction. The following example, for
+instance, simply converts any input text to upper case:
```js
const repl = require('repl');