Provide a hook for user-specified inspect functions

This commit is contained in:
Tim Caswell 2010-05-28 12:17:16 -07:00 committed by Ryan Dahl
parent 80a8e71fe0
commit 7f5320b167

View File

@ -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';