@@ -10,11 +10,30 @@ var booleanValueOf = Boolean.prototype.valueOf;
10
10
var objectToString = Object . prototype . toString ;
11
11
12
12
module . exports = function inspect_ ( obj , opts , depth , seen ) {
13
+ if ( typeof obj === 'undefined' ) {
14
+ return 'undefined' ;
15
+ }
16
+ if ( obj === null ) {
17
+ return 'null' ;
18
+ }
19
+ if ( typeof obj === 'boolean' ) {
20
+ return obj ? 'true' : 'false' ;
21
+ }
22
+ if ( typeof obj === 'string' ) {
23
+ return inspectString ( obj ) ;
24
+ }
25
+ if ( typeof obj === 'number' ) {
26
+ if ( obj === 0 ) {
27
+ return Infinity / obj > 0 ? '0' : '-0' ;
28
+ }
29
+ return String ( obj ) ;
30
+ }
31
+
13
32
if ( ! opts ) opts = { } ;
14
33
15
34
var maxDepth = typeof opts . depth === 'undefined' ? 5 : opts . depth ;
16
35
if ( typeof depth === 'undefined' ) depth = 0 ;
17
- if ( depth >= maxDepth && maxDepth > 0 && obj && typeof obj === 'object' ) {
36
+ if ( depth >= maxDepth && maxDepth > 0 && typeof obj === 'object' ) {
18
37
return '[Object]' ;
19
38
}
20
39
@@ -30,23 +49,11 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
30
49
}
31
50
return inspect_ ( value , opts , depth + 1 , seen ) ;
32
51
}
33
-
34
- if ( typeof obj === 'string' ) {
35
- return inspectString ( obj ) ;
36
- }
37
- if ( typeof obj === 'number' ) {
38
- if ( obj === 0 ) {
39
- return Infinity / obj > 0 ? '0' : '-0' ;
40
- }
41
- return String ( obj ) ;
42
- }
52
+
43
53
if ( typeof obj === 'function' ) {
44
54
var name = nameOf ( obj ) ;
45
55
return '[Function' + ( name ? ': ' + name : '' ) + ']' ;
46
56
}
47
- if ( obj === null ) {
48
- return 'null' ;
49
- }
50
57
if ( isSymbol ( obj ) ) {
51
58
var symString = Symbol . prototype . toString . call ( obj ) ;
52
59
return typeof obj === 'object' ? markBoxed ( symString ) : symString ;
@@ -102,9 +109,6 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
102
109
} ) ;
103
110
return collectionOf ( 'Set' , setSize . call ( obj ) , parts ) ;
104
111
}
105
- if ( typeof obj !== 'object' ) {
106
- return String ( obj ) ;
107
- }
108
112
if ( isNumber ( obj ) ) {
109
113
return markBoxed ( Number ( obj ) ) ;
110
114
}
0 commit comments