console: console.dir() accepts options object

This features comes from the need of adding extra options when displaying
the object using console.dir().

console.dir() accepts now a second parameter that is passed to util.inspect()
in order to provide extra options to the output. These options are: depth, color
and showHidden. More information about these options in util.inspect() documentation.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
archived-io.js-v0.10
Xavi Magrinyà 2014-06-08 13:02:54 +03:00 committed by Fedor Indutny
parent e00cafa311
commit 1cd48c7ae5
2 changed files with 5 additions and 8 deletions

View File

@ -66,12 +66,9 @@ Console.prototype.error = Console.prototype.warn;
Console.prototype.dir = function(object, options) { Console.prototype.dir = function(object, options) {
if (typeof options === 'object' && options !== null) { this._stdout.write(util.inspect(object, util._extend({
options.customInspect = false; customInspect: false
} else { }, options)) + '\n');
options = { customInspect: false };
}
this._stdout.write(util.inspect(object, options) + '\n');
}; };