diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2017-12-28 23:40:30 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-01-16 15:34:03 +0100 |
commit | b994b8eff6018433a56bb10dbc473cefa0dd9370 (patch) | |
tree | 018ee50d8c636219348747431053d7cd2a1405ca /lib | |
parent | 9d3958102ec28f2bb468b2c532b7b34cabd61f1b (diff) | |
download | android-node-v8-b994b8eff6018433a56bb10dbc473cefa0dd9370.tar.gz android-node-v8-b994b8eff6018433a56bb10dbc473cefa0dd9370.tar.bz2 android-node-v8-b994b8eff6018433a56bb10dbc473cefa0dd9370.zip |
util: change util.inspect depth default
The current default is not ideal in most use cases. Therefore it is
changed to showing unlimited depth in case util.inspect is called
directly. The default is kept as before for console.log and similar.
Using console.dir will now show a depth of up to five and
console.assert / console.trace will show a unlimited depth.
PR-URL: https://github.com/nodejs/node/pull/17907
Refs: https://github.com/nodejs/node/issues/12693
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/repl.js | 5 | ||||
-rw-r--r-- | lib/util.js | 5 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/repl.js b/lib/repl.js index 20c1c4ee92..84682b1b63 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -103,8 +103,9 @@ function hasOwnProperty(obj, prop) { // Can overridden with custom print functions, such as `probe` or `eyes.js`. // This is the default "writer" value if none is passed in the REPL options. const writer = exports.writer = (obj) => util.inspect(obj, writer.options); -writer.options = - Object.assign({}, util.inspect.defaultOptions, { showProxy: true }); +writer.options = Object.assign({}, + util.inspect.defaultOptions, + { showProxy: true, depth: 2 }); exports._builtinLibs = internalModule.builtinLibs; diff --git a/lib/util.js b/lib/util.js index e0cdc2c28f..9d1739f786 100644 --- a/lib/util.js +++ b/lib/util.js @@ -64,7 +64,7 @@ const { const inspectDefaultOptions = Object.seal({ showHidden: false, - depth: 2, + depth: null, colors: false, customInspect: true, showProxy: false, @@ -317,8 +317,7 @@ Object.defineProperty(inspect, 'defaultOptions', { if (options === null || typeof options !== 'object') { throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options', 'Object'); } - Object.assign(inspectDefaultOptions, options); - return inspectDefaultOptions; + return _extend(inspectDefaultOptions, options); } }); |