Revert "Fixes #1260"
authorRyan Dahl <ry@tinyclouds.org>
Tue, 5 Jul 2011 23:49:13 +0000 (16:49 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Tue, 5 Jul 2011 23:49:13 +0000 (16:49 -0700)
Due to downgrade of V8.

This reverts commit 3e2abd12d3534d76e480fce7a0475d228749f31d.

lib/util.js

index ae6cc2d..0239434 100644 (file)
@@ -140,13 +140,12 @@ exports.inspect = function(obj, showHidden, depth, colors) {
 
     // Functions without properties can be shortcutted.
     if (typeof value === 'function' && keys.length === 0) {
-      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');
+      if (isRegExp(value)) {
+        return stylize('' + value, 'regexp');
+      } else {
+        var name = value.name ? ': ' + value.name : '';
+        return stylize('[Function' + name + ']', 'special');
+      }
     }
 
     // Dates without properties can be shortcutted
@@ -167,16 +166,11 @@ exports.inspect = function(obj, showHidden, depth, colors) {
     // Make functions say that they are functions
     if (typeof value === 'function') {
       var n = value.name ? ': ' + value.name : '';
-      base = ' [Function' + n + ']';
+      base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']';
     } else {
       base = '';
     }
 
-    // Make RegExps say that they are RegExps
-    if (isRegExp(value)) {
-      base = ' ' + value;
-    }
-
     // Make dates with properties first say the date
     if (isDate(value)) {
       base = ' ' + value.toUTCString();
@@ -290,15 +284,15 @@ function isArray(ar) {
 
 
 function isRegExp(re) {
+  var s = '' + re;
   return re instanceof RegExp || // easy case
          // duck-type for context-switching evalcx case
-         typeof(re) === 'object' &&
-         re.constructor &&
+         typeof(re) === 'function' &&
          re.constructor.name === 'RegExp' &&
          re.compile &&
          re.test &&
          re.exec &&
-         ('' + re).match(/^\/.*\/[gim]{0,3}$/);
+         s.match(/^\/.*\/[gim]{0,3}$/);
 }