From d4b726a1a6e62c0d3a218d2f14a37b76d0878d4b Mon Sep 17 00:00:00 2001 From: Tim Cooijmans Date: Wed, 17 Nov 2010 21:26:08 +0100 Subject: [PATCH] fix utils.inspect's detection of circular structures --- lib/util.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/util.js b/lib/util.js index ac051c34d95..372fc00d723 100644 --- a/lib/util.js +++ b/lib/util.js @@ -145,8 +145,6 @@ exports.inspect = function (obj, showHidden, depth, colors) { base = ' ' + value.toUTCString(); } - seen.push(value); - if (keys.length === 0) { return braces[0] + base + braces[1]; } @@ -159,6 +157,8 @@ exports.inspect = function (obj, showHidden, depth, colors) { } } + seen.push(value); + var output = keys.map(function (key) { var name, str; if (value.__lookupGetter__) { @@ -218,6 +218,8 @@ exports.inspect = function (obj, showHidden, depth, colors) { return name + ": " + str; }); + seen.pop(); + var numLinesEst = 0; var length = output.reduce(function(prev, cur) { numLinesEst++;