Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Nathan Rajlich authored

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. +2 1  lib/util.js
3  lib/util.js
@@ -95,6 +95,7 @@ function inspect(obj, showHidden, depth, colors) {
95 95 var ctx = {
96 96 showHidden: showHidden,
97 97 seen: [],
  98 + colors: colors,
98 99 stylize: colors ? stylizeWithColor : stylizeNoColor
99 100 };
100 101 return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
@@ -158,7 +159,7 @@ function formatValue(ctx, value, recurseTimes) {
158 159 value.inspect !== exports.inspect &&
159 160 // Also filter out any prototype objects using the circular check.
160 161 !(value.constructor && value.constructor.prototype === value)) {
161   - return value.inspect(recurseTimes);
  162 + return value.inspect(recurseTimes, ctx.showHidden, ctx.colors);
162 163 }
163 164
164 165 // Primitive types cannot have properties

0 comments on commit cae6508

Please sign in to comment.
Something went wrong with that request. Please try again.