From 7f5320b1673d247229308aef5d9441dab5259e18 Mon Sep 17 00:00:00 2001 From: Tim Caswell Date: Fri, 28 May 2010 12:17:16 -0700 Subject: [PATCH] Provide a hook for user-specified inspect functions --- lib/sys.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/sys.js b/lib/sys.js index d37eab27995..7aba932205b 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -32,6 +32,11 @@ var error = exports.error = function (x) { exports.inspect = function (obj, showHidden, depth) { var seen = []; function format(value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + if (value && typeof value.inspect === 'function') { + return value.inspect(recurseTimes); + } + // Primitive types cannot have properties switch (typeof value) { case 'undefined': return 'undefined';