summaryrefslogtreecommitdiff
path: root/doc/api/util.md
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-03-26 15:53:11 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-04-04 12:48:57 +0200
commita9bf6652b5353f2098d4c0cd0eb77d17e02e164d (patch)
tree3c62cdca11156d359979e251883605aeee3b033e /doc/api/util.md
parentadbcda1eef4377c6fd0c88a1df1003e1e100ffbe (diff)
downloadandroid-node-v8-a9bf6652b5353f2098d4c0cd0eb77d17e02e164d.tar.gz
android-node-v8-a9bf6652b5353f2098d4c0cd0eb77d17e02e164d.tar.bz2
android-node-v8-a9bf6652b5353f2098d4c0cd0eb77d17e02e164d.zip
util: use minimal object inspection with %s specifier
This improves `util.format()` by returning more meaningful results when using `%s` as specifier and any object as value. Besides that `BigInt` will also be represented with an `n` at the end to indicate that it's of type `BigInt`. PR-URL: https://github.com/nodejs/node/pull/26927 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'doc/api/util.md')
-rw-r--r--doc/api/util.md20
1 files changed, 11 insertions, 9 deletions
diff --git a/doc/api/util.md b/doc/api/util.md
index beb79ae0f8..6a8b30ef7a 100644
--- a/doc/api/util.md
+++ b/doc/api/util.md
@@ -220,15 +220,17 @@ as a `printf`-like format string which can contain zero or more format
specifiers. Each specifier is replaced with the converted value from the
corresponding argument. Supported specifiers are:
-* `%s` - `String`.
-* `%d` - `Number` (integer or floating point value) or `BigInt`.
-* `%i` - Integer or `BigInt`.
-* `%f` - Floating point value.
-* `%j` - JSON. Replaced with the string `'[Circular]'` if the argument
-contains circular references.
-* `%o` - `Object`. A string representation of an object
- with generic JavaScript object formatting.
- Similar to `util.inspect()` with options
+* `%s` - `String` will be used to convert all values except `BigInt` and
+ `Object`. `BigInt` values will be represented with an `n` and Objects are
+ inspected using `util.inspect()` with options
+ `{ depth: 0, colors: false, compact: 3 }`.
+* `%d` - `Number` will be used to convert all values except `BigInt`.
+* `%i` - `parseInt(value, 10)` is used for all values except `BigInt`.
+* `%f` - `parseFloat(value)` is used for all values.
+* `%j` - JSON. Replaced with the string `'[Circular]'` if the argument contains
+ circular references.
+* `%o` - `Object`. A string representation of an object with generic JavaScript
+ object formatting. 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