(ctx, value, recurseTimes)
| 29696 | |
| 29697 | |
| 29698 | function formatValue(ctx, value, recurseTimes) { |
| 29699 | // Provide a hook for user-specified inspect functions. |
| 29700 | // Check that value is an object with an inspect function on it |
| 29701 | if (ctx.customInspect && |
| 29702 | value && |
| 29703 | isFunction(value.inspect) && |
| 29704 | // Filter out the util module, it's inspect function is special |
| 29705 | value.inspect !== exports.inspect && |
| 29706 | // Also filter out any prototype objects using the circular check. |
| 29707 | !(value.constructor && value.constructor.prototype === value)) { |
| 29708 | var ret = value.inspect(recurseTimes, ctx); |
| 29709 | if (!isString(ret)) { |
| 29710 | ret = formatValue(ctx, ret, recurseTimes); |
| 29711 | } |
| 29712 | return ret; |
| 29713 | } |
| 29714 | |
| 29715 | // Primitive types cannot have properties |
| 29716 | var primitive = formatPrimitive(ctx, value); |
| 29717 | if (primitive) { |
| 29718 | return primitive; |
| 29719 | } |
| 29720 | |
| 29721 | // Look up the keys of the object. |
| 29722 | var keys = Object.keys(value); |
| 29723 | var visibleKeys = arrayToHash(keys); |
| 29724 | |
| 29725 | if (ctx.showHidden) { |
| 29726 | keys = Object.getOwnPropertyNames(value); |
| 29727 | } |
| 29728 | |
| 29729 | // IE doesn't make error fields non-enumerable |
| 29730 | // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx |
| 29731 | if (isError(value) |
| 29732 | && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { |
| 29733 | return formatError(value); |
| 29734 | } |
| 29735 | |
| 29736 | // Some type of object without properties can be shortcutted. |
| 29737 | if (keys.length === 0) { |
| 29738 | if (isFunction(value)) { |
| 29739 | var name = value.name ? ': ' + value.name : ''; |
| 29740 | return ctx.stylize('[Function' + name + ']', 'special'); |
| 29741 | } |
| 29742 | if (isRegExp(value)) { |
| 29743 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); |
| 29744 | } |
| 29745 | if (isDate(value)) { |
| 29746 | return ctx.stylize(Date.prototype.toString.call(value), 'date'); |
| 29747 | } |
| 29748 | if (isError(value)) { |
| 29749 | return formatError(value); |
| 29750 | } |
| 29751 | } |
| 29752 | |
| 29753 | var base = '', array = false, braces = ['{', '}']; |
| 29754 | |
| 29755 | // Make Array say that they are Array |
no test coverage detected