Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pass the 'showHidden' and 'colors' to custom inspect() functions.

Previously, it was impossible to determine whether or not 'colors'
should be used in a custom inspect() function, which was a flaw.

Passing all the necessary variables is the propery way to do it.

The order of variables passed doesn't quite match `util.inspect()`, for
legacy purposes.
  • Loading branch information...
commit cae65086151d4e98327b70f37f1846b8d94903b2 1 parent 4b3824b
@TooTallNate authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  lib/util.js
View
3  lib/util.js
@@ -95,6 +95,7 @@ function inspect(obj, showHidden, depth, colors) {
var ctx = {
showHidden: showHidden,
seen: [],
+ colors: colors,
stylize: colors ? stylizeWithColor : stylizeNoColor
};
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
@@ -158,7 +159,7 @@ function formatValue(ctx, value, recurseTimes) {
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
- return value.inspect(recurseTimes);
+ return value.inspect(recurseTimes, ctx.showHidden, ctx.colors);
}
// Primitive types cannot have properties
Please sign in to comment.
Something went wrong with that request. Please try again.