(value, recurseTimes)
| 565 | }; |
| 566 | |
| 567 | function format (value, recurseTimes) { |
| 568 | // Provide a hook for user-specified inspect functions. |
| 569 | // Check that value is an object with an inspect function on it |
| 570 | if (value && typeof value.inspect === 'function' && |
| 571 | // Filter out the util module, it's inspect function is special |
| 572 | value !== exports && |
| 573 | // Also filter out any prototype objects using the circular check. |
| 574 | !(value.constructor && value.constructor.prototype === value)) { |
| 575 | return value.inspect(recurseTimes); |
| 576 | } |
| 577 | |
| 578 | // Primitive types cannot have properties |
| 579 | switch (typeof value) { |
| 580 | case 'undefined': |
| 581 | return stylize('undefined', 'undefined'); |
| 582 | |
| 583 | case 'string': |
| 584 | var simple = '\'' + json.stringify(value).replace(/^"|"$/g, '') |
| 585 | .replace(/'/g, "\\'") |
| 586 | .replace(/\\"/g, '"') + '\''; |
| 587 | return stylize(simple, 'string'); |
| 588 | |
| 589 | case 'number': |
| 590 | return stylize('' + value, 'number'); |
| 591 | |
| 592 | case 'boolean': |
| 593 | return stylize('' + value, 'boolean'); |
| 594 | } |
| 595 | // For some reason typeof null is "object", so special case here. |
| 596 | if (value === null) { |
| 597 | return stylize('null', 'null'); |
| 598 | } |
| 599 | |
| 600 | if (isDOMElement(value)) { |
| 601 | return getOuterHTML(value); |
| 602 | } |
| 603 | |
| 604 | // Look up the keys of the object. |
| 605 | var visible_keys = keys(value); |
| 606 | var $keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys; |
| 607 | |
| 608 | // Functions without properties can be shortcutted. |
| 609 | if (typeof value === 'function' && $keys.length === 0) { |
| 610 | if (isRegExp(value)) { |
| 611 | return stylize('' + value, 'regexp'); |
| 612 | } else { |
| 613 | var name = value.name ? ': ' + value.name : ''; |
| 614 | return stylize('[Function' + name + ']', 'special'); |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | // Dates without properties can be shortcutted |
| 619 | if (isDate(value) && $keys.length === 0) { |
| 620 | return stylize(value.toUTCString(), 'date'); |
| 621 | } |
| 622 | |
| 623 | var base, type, braces; |
| 624 | // Determine the object type |
no test coverage detected
searching dependent graphs…