From 24c8fdc1d06e7404992553aea85c74ee2239f397 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 3 Apr 2015 01:47:05 +0200 Subject: [PATCH] do not print Plain Object prototype fields in geth console --- jsre/pp_js.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jsre/pp_js.go b/jsre/pp_js.go index 3c0de37e5..2badb90e7 100644 --- a/jsre/pp_js.go +++ b/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) {