Fixes #1260
RegExp object is no longer Function. http://code.google.com/p/v8/issues/detail?id=617
This commit is contained in:
parent
6d8b43c366
commit
3e2abd12d3
26
lib/util.js
26
lib/util.js
@ -140,12 +140,13 @@ exports.inspect = function(obj, showHidden, depth, colors) {
|
|||||||
|
|
||||||
// Functions without properties can be shortcutted.
|
// Functions without properties can be shortcutted.
|
||||||
if (typeof value === 'function' && keys.length === 0) {
|
if (typeof value === 'function' && keys.length === 0) {
|
||||||
if (isRegExp(value)) {
|
var name = value.name ? ': ' + value.name : '';
|
||||||
return stylize('' + value, 'regexp');
|
return stylize('[Function' + name + ']', 'special');
|
||||||
} else {
|
}
|
||||||
var name = value.name ? ': ' + value.name : '';
|
|
||||||
return stylize('[Function' + name + ']', 'special');
|
// RegExp without properties can be shortcutted
|
||||||
}
|
if (isRegExp(value) && keys.length === 0) {
|
||||||
|
return stylize('' + value, 'regexp');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dates without properties can be shortcutted
|
// Dates without properties can be shortcutted
|
||||||
@ -166,11 +167,16 @@ exports.inspect = function(obj, showHidden, depth, colors) {
|
|||||||
// Make functions say that they are functions
|
// Make functions say that they are functions
|
||||||
if (typeof value === 'function') {
|
if (typeof value === 'function') {
|
||||||
var n = value.name ? ': ' + value.name : '';
|
var n = value.name ? ': ' + value.name : '';
|
||||||
base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']';
|
base = ' [Function' + n + ']';
|
||||||
} else {
|
} else {
|
||||||
base = '';
|
base = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make RegExps say that they are RegExps
|
||||||
|
if (isRegExp(value)) {
|
||||||
|
base = ' ' + value;
|
||||||
|
}
|
||||||
|
|
||||||
// Make dates with properties first say the date
|
// Make dates with properties first say the date
|
||||||
if (isDate(value)) {
|
if (isDate(value)) {
|
||||||
base = ' ' + value.toUTCString();
|
base = ' ' + value.toUTCString();
|
||||||
@ -284,15 +290,15 @@ function isArray(ar) {
|
|||||||
|
|
||||||
|
|
||||||
function isRegExp(re) {
|
function isRegExp(re) {
|
||||||
var s = '' + re;
|
|
||||||
return re instanceof RegExp || // easy case
|
return re instanceof RegExp || // easy case
|
||||||
// duck-type for context-switching evalcx case
|
// duck-type for context-switching evalcx case
|
||||||
typeof(re) === 'function' &&
|
typeof(re) === 'object' &&
|
||||||
|
re.constructor &&
|
||||||
re.constructor.name === 'RegExp' &&
|
re.constructor.name === 'RegExp' &&
|
||||||
re.compile &&
|
re.compile &&
|
||||||
re.test &&
|
re.test &&
|
||||||
re.exec &&
|
re.exec &&
|
||||||
s.match(/^\/.*\/[gim]{0,3}$/);
|
('' + re).match(/^\/.*\/[gim]{0,3}$/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user