doc: update util.format formatters documentation

This includes the information that some inputs are handled
differently than others (e.g., `Symbols` are partially represented
as `NaN`).

PR-URL: https://github.com/nodejs/node/pull/27621
Reviewed-By: Roman Reiss <me@silverwind.io>
This commit is contained in:
Ruben Bridgewater 2019-05-14 00:23:07 +02:00
parent 32fb7d9334
commit 182b48aa77
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -220,13 +220,15 @@ as a `printf`-like format string which can contain zero or more format
specifiers. Each specifier is replaced with the converted value from the specifiers. Each specifier is replaced with the converted value from the
corresponding argument. Supported specifiers are: corresponding argument. Supported specifiers are:
* `%s` - `String` will be used to convert all values except `BigInt` and * `%s` - `String` will be used to convert all values except `BigInt`, `Object`
`Object`. `BigInt` values will be represented with an `n` and Objects are and `-0`. `BigInt` values will be represented with an `n` and Objects are
inspected using `util.inspect()` with options inspected using `util.inspect()` with options
`{ depth: 0, colors: false, compact: 3 }`. `{ depth: 0, colors: false, compact: 3 }`.
* `%d` - `Number` will be used to convert all values except `BigInt`. * `%d` - `Number` will be used to convert all values except `BigInt` and
* `%i` - `parseInt(value, 10)` is used for all values except `BigInt`. `Symbol`.
* `%f` - `parseFloat(value)` is used for all values. * `%i` - `parseInt(value, 10)` is used for all values except `BigInt` and
`Symbol`.
* `%f` - `parseFloat(value)` is used for all values expect `Symbol`.
* `%j` - JSON. Replaced with the string `'[Circular]'` if the argument contains * `%j` - JSON. Replaced with the string `'[Circular]'` if the argument contains
circular references. circular references.
* `%o` - `Object`. A string representation of an object with generic JavaScript * `%o` - `Object`. A string representation of an object with generic JavaScript