From 1fbfc1be95a16e0da4783ca800c79bc329fd5f5f Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 17 Sep 2019 18:34:33 +0200 Subject: [PATCH 1/3] doc: update util.format's changes entries This reduces the information and sorts the entries. --- doc/api/util.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index fdb90505b1c0ec..8f9ac232c1c842 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -188,21 +188,16 @@ changes: - version: v12.11.0 pr-url: https://github.com/nodejs/node/pull/29606 description: The `%c` specifier is ignored now. + - version: v12.0.0 + pr-url: https://github.com/nodejs/node/pull/23162 + description: The output string's formatting is no longer dependent on the + type of the first argument. This change removes previously + present quotes from strings that were being output when the + first argument was not a string. - version: v11.4.0 pr-url: https://github.com/nodejs/node/pull/23708 description: The `%d`, `%f` and `%i` specifiers now support Symbols properly. - - version: v12.0.0 - pr-url: https://github.com/nodejs/node/pull/23162 - description: The `format` argument is now only taken as such if it actually - contains format specifiers. - - version: v12.0.0 - pr-url: https://github.com/nodejs/node/pull/23162 - description: If the `format` argument is not a format string, the output - string's formatting is no longer dependent on the type of the - first argument. This change removes previously present quotes - from strings that were being output when the first argument - was not a string. - version: v11.4.0 pr-url: https://github.com/nodejs/node/pull/24806 description: The `%o` specifier's `depth` has default depth of 4 again. From ddc27dcf4910c30be6737826a450b1452a451b23 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 17 Sep 2019 19:12:17 +0200 Subject: [PATCH 2/3] doc: fix format arguments description --- doc/api/util.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index 8f9ac232c1c842..475df2e227929f 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -181,7 +181,7 @@ The `--throw-deprecation` command line flag and `process.throwDeprecation` property take precedence over `--trace-deprecation` and `process.traceDeprecation`. -## util.format(format\[, ...args\]) +## util.format(\[format\]\[, ...args\]) * `format` {string} A `printf`-like format string. +* `...args` {any} +* Returns: {string} The formatted string The `util.format()` method returns a formatted string using the first argument as a `printf`-like format string which can contain zero or more format @@ -241,7 +243,6 @@ corresponding argument. Supported specifiers are: * `%c` - `CSS`. This specifier is currently ignored, and will skip any CSS passed in. * `%%` - single percent sign (`'%'`). This does not consume an argument. -* Returns: {string} The formatted string If a specifier does not have a corresponding argument, it is not replaced: @@ -282,13 +283,15 @@ util.format('%% %s'); Some input values can have a significant performance overhead that can block the event loop. Use this function with care and never in a hot code path. -## util.formatWithOptions(inspectOptions, format\[, ...args\]) +## util.formatWithOptions(inspectOptions\[, format\]\[, ...args\]) * `inspectOptions` {Object} * `format` {string} +* `...args` {any} +* Returns: {string} This function is identical to [`util.format()`][], except in that it takes an `inspectOptions` argument which specifies options that are passed along to From 82477e1b0f8d35e726823b8f3661d810dc35bca0 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 17 Sep 2019 18:43:58 +0200 Subject: [PATCH 3/3] console,util: inspect strings as in < Node.js v12.x This reverts https://github.com/nodejs/node/pull/23162. The gained consistency did not outweight the benefit of inspecting the arguments. Therefore it is best to revert to the former behavior. Refs: https://github.com/nodejs/node/issues/29539 Refs: https://github.com/nodejs/node/pull/23162 --- doc/api/util.md | 45 ++++++++++++++++++------------- lib/internal/util/inspect.js | 6 ++++- test/parallel/test-util-format.js | 18 +++++++++---- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index 475df2e227929f..ba6cc8ee3827b3 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -185,6 +185,10 @@ property take precedence over `--trace-deprecation` and