Skip to content

Commit

Permalink
util: change %o depth default
Browse files Browse the repository at this point in the history
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: nodejs#17907
Refs: nodejs#12693
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
BridgeAR committed Jan 16, 2018
1 parent b994b8e commit 8f15309
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ property take precedence over `--trace-deprecation` and
<!-- YAML
added: v0.5.3
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/17907
description: The `%o` specifiers `depth` option is now set to Infinity.
- version: v8.4.0
pr-url: https://github.com/nodejs/node/pull/14558
description: The `%o` and `%O` specifiers are supported now.
Expand All @@ -209,12 +212,11 @@ corresponding argument. Supported placeholders are:
contains circular references.
* `%o` - Object. A string representation of an object
with generic JavaScript object formatting.
Similar to `util.inspect()` with options `{ showHidden: true, depth: 4, showProxy: true }`.
This will show the full object including non-enumerable symbols and properties.
* `%O` - Object. A string representation of an object
with generic JavaScript object formatting.
Similar to `util.inspect()` without options.
This will show the full object not including non-enumerable symbols and properties.
Similar to `util.inspect()` with options `{ showHidden: true, showProxy: true }`.
This will show the full object including non-enumerable properties and proxies.
* `%O` - Object. A string representation of an object with generic JavaScript
object formatting. Similar to `util.inspect()` without options. This will show
the full object not including non-enumerable properties and proxies.
* `%%` - single percent sign (`'%'`). This does not consume an argument.

If the placeholder does not have a corresponding argument, the placeholder is
Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function format(f) {
break;
case 111: // 'o'
tempStr = inspect(arguments[a++],
{ showHidden: true, depth: 4, showProxy: true });
{ showHidden: true, showProxy: true });
break;
case 105: // 'i'
tempStr = `${parseInt(arguments[a++])}`;
Expand Down

0 comments on commit 8f15309

Please sign in to comment.