Skip to content

Commit

Permalink
console, doc, test: corrections following review
Browse files Browse the repository at this point in the history
Nits in documentation, rework dirxml to use console.log, tests.

Fixes: #17128
  • Loading branch information
Tiriel committed Nov 24, 2017
1 parent 6319499 commit a8ea202
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
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

0 comments on commit a8ea202

Please sign in to comment.