Skip to content

Commit d1eba2b

Browse files
committed
Revert "Fixes #1260"
Due to downgrade of V8. This reverts commit 3e2abd1.
1 parent 8b2f5af commit d1eba2b

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

lib/util.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,12 @@ exports.inspect = function(obj, showHidden, depth, colors) {
140140

141141
// Functions without properties can be shortcutted.
142142
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+
}
150149
}
151150

152151
// Dates without properties can be shortcutted
@@ -167,16 +166,11 @@ exports.inspect = function(obj, showHidden, depth, colors) {
167166
// Make functions say that they are functions
168167
if (typeof value === 'function') {
169168
var n = value.name ? ': ' + value.name : '';
170-
base = ' [Function' + n + ']';
169+
base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']';
171170
} else {
172171
base = '';
173172
}
174173

175-
// Make RegExps say that they are RegExps
176-
if (isRegExp(value)) {
177-
base = ' ' + value;
178-
}
179-
180174
// Make dates with properties first say the date
181175
if (isDate(value)) {
182176
base = ' ' + value.toUTCString();
@@ -290,15 +284,15 @@ function isArray(ar) {
290284

291285

292286
function isRegExp(re) {
287+
var s = '' + re;
293288
return re instanceof RegExp || // easy case
294289
// duck-type for context-switching evalcx case
295-
typeof(re) === 'object' &&
296-
re.constructor &&
290+
typeof(re) === 'function' &&
297291
re.constructor.name === 'RegExp' &&
298292
re.compile &&
299293
re.test &&
300294
re.exec &&
301-
('' + re).match(/^\/.*\/[gim]{0,3}$/);
295+
s.match(/^\/.*\/[gim]{0,3}$/);
302296
}
303297

304298

0 commit comments

Comments
 (0)