瀏覽代碼

do not print Plain Object prototype fields in geth console

Marek Kotewicz 10 年之前
父節點
當前提交
24c8fdc1d0
共有 1 個文件被更改,包括 13 次插入1 次删除
  1. 13 1
      jsre/pp_js.go

+ 13 - 1
jsre/pp_js.go

@@ -63,12 +63,24 @@ function pp(object, indent) {
     return str;
 }
 
+var redundantFields = [
+    'valueOf',
+    'toString',
+    'toLocaleString',
+    'hasOwnProperty',
+    'isPrototypeOf',
+    'propertyIsEnumerable',
+    'constructor'
+];
+
 var getFields = function (object) {
     var result = Object.getOwnPropertyNames(object);
     if (object.constructor && object.constructor.prototype) {
         result = result.concat(Object.getOwnPropertyNames(object.constructor.prototype));
     }
-    return result;
+    return result.filter(function (field) {
+        return redundantFields.indexOf(field) === -1;
+    });
 };
 
 var isBigNumber = function (object) {