@@ -140,13 +140,12 @@ exports.inspect = function(obj, showHidden, depth, colors) {
140
140
141
141
// Functions without properties can be shortcutted.
142
142
if ( typeof value === 'function' && keys . length === 0 ) {
143
- var name = value . name ? ': ' + value . name : '' ;
144
- return stylize ( '[Function' + name + ']' , 'special' ) ;
145
- }
146
-
147
- // RegExp without properties can be shortcutted
148
- if ( isRegExp ( value ) && keys . length === 0 ) {
149
- return stylize ( '' + value , 'regexp' ) ;
143
+ if ( isRegExp ( value ) ) {
144
+ return stylize ( '' + value , 'regexp' ) ;
145
+ } else {
146
+ var name = value . name ? ': ' + value . name : '' ;
147
+ return stylize ( '[Function' + name + ']' , 'special' ) ;
148
+ }
150
149
}
151
150
152
151
// Dates without properties can be shortcutted
@@ -167,16 +166,11 @@ exports.inspect = function(obj, showHidden, depth, colors) {
167
166
// Make functions say that they are functions
168
167
if ( typeof value === 'function' ) {
169
168
var n = value . name ? ': ' + value . name : '' ;
170
- base = ' [Function' + n + ']' ;
169
+ base = ( isRegExp ( value ) ) ? ' ' + value : ' [Function' + n + ']' ;
171
170
} else {
172
171
base = '' ;
173
172
}
174
173
175
- // Make RegExps say that they are RegExps
176
- if ( isRegExp ( value ) ) {
177
- base = ' ' + value ;
178
- }
179
-
180
174
// Make dates with properties first say the date
181
175
if ( isDate ( value ) ) {
182
176
base = ' ' + value . toUTCString ( ) ;
@@ -290,15 +284,15 @@ function isArray(ar) {
290
284
291
285
292
286
function isRegExp ( re ) {
287
+ var s = '' + re ;
293
288
return re instanceof RegExp || // easy case
294
289
// duck-type for context-switching evalcx case
295
- typeof ( re ) === 'object' &&
296
- re . constructor &&
290
+ typeof ( re ) === 'function' &&
297
291
re . constructor . name === 'RegExp' &&
298
292
re . compile &&
299
293
re . test &&
300
294
re . exec &&
301
- ( '' + re ) . match ( / ^ \/ .* \/ [ g i m ] { 0 , 3 } $ / ) ;
295
+ s . match ( / ^ \/ .* \/ [ g i m ] { 0 , 3 } $ / ) ;
302
296
}
303
297
304
298
0 commit comments