diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-05-09 09:22:15 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-05-20 14:18:18 +0200 |
commit | 5518664d41b8916dfbe2eca2180d760db632748e (patch) | |
tree | 38b36fd6e4ba56e5a0ef1a0955fc495270675144 /doc/api/util.md | |
parent | 182b48aa777a2c9c453f729c162412b6900b055d (diff) | |
download | android-node-v8-5518664d41b8916dfbe2eca2180d760db632748e.tar.gz android-node-v8-5518664d41b8916dfbe2eca2180d760db632748e.tar.bz2 android-node-v8-5518664d41b8916dfbe2eca2180d760db632748e.zip |
util: if present, fallback to `toString` using the %s formatter
This makes sure that `util.format` uses `String` to stringify an object
in case the object has an own property named `toString` with type
`function`. That way objects that do not have such function are still
inspected using `util.inspect` and the old behavior is preserved as
well.
PR-URL: https://github.com/nodejs/node/pull/27621
Refs: https://github.com/facebook/jest/issues/8443
Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'doc/api/util.md')
-rw-r--r-- | doc/api/util.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/api/util.md b/doc/api/util.md index e0b30e9a97..301089fd47 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -221,9 +221,9 @@ specifiers. Each specifier is replaced with the converted value from the corresponding argument. Supported specifiers are: * `%s` - `String` will be used to convert all values except `BigInt`, `Object` - and `-0`. `BigInt` values will be represented with an `n` and Objects are - inspected using `util.inspect()` with options - `{ depth: 0, colors: false, compact: 3 }`. + and `-0`. `BigInt` values will be represented with an `n` and Objects that + have no user defined `toString` function are inspected using `util.inspect()` + with options `{ depth: 0, colors: false, compact: 3 }`. * `%d` - `Number` will be used to convert all values except `BigInt` and `Symbol`. * `%i` - `parseInt(value, 10)` is used for all values except `BigInt` and |