Skip to content

Commit

Permalink
console: add dirxml method
Browse files Browse the repository at this point in the history
This method was previously exposed by V8 (since Node v8.0.0) and not
implemented in Node directly.
Tests coming soon.

Refs: #17128
  • Loading branch information
Tiriel committed Nov 24, 2017
1 parent 6f724e1 commit 52fefd4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,25 @@ Console.prototype.dir = function dir(object, options) {
};


Console.prototype.dirxml = function dirxml(...data) {
const optionProps = ['showHidden', 'depth', 'colors'],
maybeOptions = Object.getOwnPropertyNames(data.slice(-1)),
isOption = maybeOptions.some((p) => optionProps.indexOf(p) !== -1);
let options = { customInspect: false };

if (isOption) {
options = Object.assign(data.splice(-1), options);
}
for (const item of data) {
write(this._ignoreErrors,
this._stdout,
util.inspect(item, options),
this._stdoutErrorHandler,
this[kGroupIndent]);
}
};


Console.prototype.time = function time(label = 'default') {
// Coerces everything other than Symbol to a string
label = `${label}`;
Expand Down

0 comments on commit 52fefd4

Please sign in to comment.