Skip to content

Commit 8f15309

Browse files
committed
util: change %o depth default
Since the default for depth is changed to `Infinity` it is logical to change the %o default to the same as well. Using %o with `util.format` will now always print the whole object. PR-URL: #17907 Refs: #12693 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent b994b8e commit 8f15309

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

doc/api/util.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ property take precedence over `--trace-deprecation` and
187187
<!-- YAML
188188
added: v0.5.3
189189
changes:
190+
- version: REPLACEME
191+
pr-url: https://github.com/nodejs/node/pull/17907
192+
description: The `%o` specifiers `depth` option is now set to Infinity.
190193
- version: v8.4.0
191194
pr-url: https://github.com/nodejs/node/pull/14558
192195
description: The `%o` and `%O` specifiers are supported now.
@@ -209,12 +212,11 @@ corresponding argument. Supported placeholders are:
209212
contains circular references.
210213
* `%o` - Object. A string representation of an object
211214
with generic JavaScript object formatting.
212-
Similar to `util.inspect()` with options `{ showHidden: true, depth: 4, showProxy: true }`.
213-
This will show the full object including non-enumerable symbols and properties.
214-
* `%O` - Object. A string representation of an object
215-
with generic JavaScript object formatting.
216-
Similar to `util.inspect()` without options.
217-
This will show the full object not including non-enumerable symbols and properties.
215+
Similar to `util.inspect()` with options `{ showHidden: true, showProxy: true }`.
216+
This will show the full object including non-enumerable properties and proxies.
217+
* `%O` - Object. A string representation of an object with generic JavaScript
218+
object formatting. Similar to `util.inspect()` without options. This will show
219+
the full object not including non-enumerable properties and proxies.
218220
* `%%` - single percent sign (`'%'`). This does not consume an argument.
219221

220222
If the placeholder does not have a corresponding argument, the placeholder is

lib/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function format(f) {
195195
break;
196196
case 111: // 'o'
197197
tempStr = inspect(arguments[a++],
198-
{ showHidden: true, depth: 4, showProxy: true });
198+
{ showHidden: true, showProxy: true });
199199
break;
200200
case 105: // 'i'
201201
tempStr = `${parseInt(arguments[a++])}`;

0 commit comments

Comments
 (0)