Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
console, doc, test: corrections following review
Nits in documentation, rework dirxml to use console.log, tests.

Fixes: #17128
  • Loading branch information
Tiriel committed Nov 24, 2017
commit a8ea202a385baeffca4920546bf28eb3ee075b9c
11 changes: 4 additions & 7 deletions doc/api/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,13 @@ Defaults to `false`. Colors are customizable; see
added: v8.0.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/17128
description: "`console.dirxml` now calls `console.dir` for each argument."
pr-url: https://github.com/nodejs/node/pull/17152
description: "`console.dirxml` now calls `console.log` for its arguments."
-->
* `...data` {any}

This method calls `console.dir()` with default options for each argument it
receives. See [`console.dir()`][] for more details about said defaults.
Please note that this method doesn't produce any xml formatting and uses the
default `console.dir()` formatting resolution instead.
This method calls `console.log()` passing it the arguments received.
Please note that this method does not produce any XML formatting.

### console.error([data][, ...args])
<!-- YAML
Expand Down Expand Up @@ -524,7 +522,6 @@ added: v8.0.0
This method does not display anything unless used in the inspector. The
`console.timelineEnd()` method is the deprecated form of [`console.timeEnd()`][].

[`console.dir()`]: #console_console_dir_obj_options
[`console.error()`]: #console_console_error_data_args
[`console.group()`]: #console_console_group_label
[`console.log()`]: #console_console_log_data_args
Expand Down
6 changes: 1 addition & 5 deletions lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ Console.prototype.dir = function dir(object, options) {
};


Console.prototype.dirxml = function dirxml(...data) {
for (const item of data) {
Console.prototype.dir.call(this, item);
}
};
Console.prototype.dirxml = Console.prototype.log;


Console.prototype.time = function time(label = 'default') {
Expand Down
11 changes: 4 additions & 7 deletions test/parallel/test-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,10 @@ assert.strictEqual(strings.shift(),
"{ foo: 'bar', inspect: [Function: inspect] }\n");
assert.ok(strings.shift().includes('foo: [Object]'));
assert.strictEqual(strings.shift().includes('baz'), false);
assert.strictEqual(strings.shift(),
"{ foo: 'bar', inspect: [Function: inspect] }\n");
assert.strictEqual(strings.shift(),
"{ foo: 'bar', inspect: [Function: inspect] }\n");
assert.strictEqual(strings.shift().includes('foo: { bar: { baz:'), true);
assert.strictEqual(strings.shift().includes('quux'), true);
assert.strictEqual(strings.shift().includes('quux: true'), true);
assert.strictEqual(strings.shift(), 'inspect inspect\n');
assert.ok(strings[0].includes('foo: { bar: { baz:'));
assert.ok(strings[0].includes('quux'));
assert.ok(strings.shift().includes('quux: true'));

assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim()));
assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim()));
Expand Down