Provide a hook for user-specified inspect functions
This commit is contained in:
parent
80a8e71fe0
commit
7f5320b167
@ -32,6 +32,11 @@ var error = exports.error = function (x) {
|
|||||||
exports.inspect = function (obj, showHidden, depth) {
|
exports.inspect = function (obj, showHidden, depth) {
|
||||||
var seen = [];
|
var seen = [];
|
||||||
function format(value, recurseTimes) {
|
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
|
// Primitive types cannot have properties
|
||||||
switch (typeof value) {
|
switch (typeof value) {
|
||||||
case 'undefined': return 'undefined';
|
case 'undefined': return 'undefined';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user