-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Closed
Labels
questionIssues that look for answers.Issues that look for answers.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
Description
- Version: v12.11.0
- Platform: Linux tiagonapoli-Inspiron-7460 5.0.0-29-generic Updates README with IRC channel for #io.js #31-Ubuntu SMP Thu Sep 12 13:05:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
The following snippet shows a possible unexpected output for formatWithOptions
. On console.log(util.formatWithOptions({ }, '%s', obj))
I expected a output { a: [ '123' ] }
, but got { a: [Array] }
:
const util = require('util')
const obj = { a: ['123'] }
/************ formatWithOptions ************/
// { a: [Array] }
console.log(util.formatWithOptions({ }, '%s', obj))
// { a: [ '123' ] } - Note: this is not respecting the api docs, the first argument has to be an object
console.log(util.formatWithOptions('%s', obj))
/******************************************/
/************ inspect ************/
// { a: [ '123' ] }
console.log(util.inspect(obj, { }))
// { a: [ '123' ] }
console.log(util.inspect(obj))
/*******************************/
Since util.formatWithOptions('%s', obj)
doesn't respect the api docs, maybe this is an expected behavior for util.formatWithOptions
, in this case maybe it could be changed to have similar behavior to inspect?
Metadata
Metadata
Assignees
Labels
questionIssues that look for answers.Issues that look for answers.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.