-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
console: add dirxml method #17152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
console: add dirxml method #17152
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…eceived. Minimal implementation following the Living Standard specs, following reviews. Fixes: #17128
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,6 +277,21 @@ Defaults to `2`. To make it recurse indefinitely, pass `null`. | |
| Defaults to `false`. Colors are customizable; see | ||
| [customizing `util.inspect()` colors][]. | ||
|
|
||
| ### console.dirxml(...data) | ||
| <!-- YAML | ||
| 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." | ||
| --> | ||
| * `...data` {any} | ||
|
|
||
| This method calls `console.dir()` with default options for each argument it | ||
| receives. See [`console.dir()`][] for more details about said defaults. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will require some changes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Damn, sorry about that. Fixing right now and squashing.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! |
||
| Please note that this method doesn't produce any xml formatting and uses the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Please use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
| default `console.dir()` formatting resolution instead. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a native English speaker myself, but
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I'll just let the precision on the absence of XML formatting then, just to be sure it's clear for everyone. But I thought resolution was indicated, you have me doubting now 😄 |
||
|
|
||
| ### console.error([data][, ...args]) | ||
| <!-- YAML | ||
| added: v0.1.100 | ||
|
|
@@ -435,18 +450,6 @@ The following methods are exposed by the V8 engine in the general API but do | |
| not display anything unless used in conjunction with the [inspector][] | ||
| (`--inspect` flag). | ||
|
|
||
| ### console.dirxml(object) | ||
| <!-- YAML | ||
| added: v8.0.0 | ||
| --> | ||
| * `object` {string} | ||
|
|
||
| This method does not display anything unless used in the inspector. The | ||
| `console.dirxml()` method displays in `stdout` an XML interactive tree | ||
| representation of the descendants of the specified `object` if possible, or the | ||
| JavaScript representation if not. Calling `console.dirxml()` on an HTML or XML | ||
| element is equivalent to calling `console.log()`. | ||
|
|
||
| ### console.markTimeline(label) | ||
| <!-- YAML | ||
| added: v8.0.0 | ||
|
|
@@ -521,6 +524,7 @@ 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,14 @@ console.dir(custom_inspect, { showHidden: false }); | |
| console.dir({ foo: { bar: { baz: true } } }, { depth: 0 }); | ||
| console.dir({ foo: { bar: { baz: true } } }, { depth: 1 }); | ||
|
|
||
| // test console.dirxml() | ||
| console.dirxml(custom_inspect, custom_inspect); | ||
| console.dirxml( | ||
| { foo: { bar: { baz: true } } }, | ||
| { foo: { bar: { quux: false } } }, | ||
| { foo: { bar: { quux: true } } } | ||
| ); | ||
|
|
||
| // test console.trace() | ||
| console.trace('This is a %j %d', { formatted: 'trace' }, 10, 'foo'); | ||
|
|
||
|
|
@@ -171,6 +179,14 @@ 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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't know, sorry. Thanks!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem, thanks for going through our (sometimes a little long) process! |
||
|
|
||
| assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim())); | ||
| assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim())); | ||
| assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim())); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This should be
https://github.com/nodejs/node/pull/17152as far as I can tell.