From 1f122626be082055380b2b2bc8440d0a319be4cc Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 3 Apr 2015 00:49:18 +0200 Subject: [PATCH] printing object prototype functions in geth console --- jsre/pp_js.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jsre/pp_js.go b/jsre/pp_js.go index 0b22afe6d..3c0de37e5 100644 --- a/jsre/pp_js.go +++ b/jsre/pp_js.go @@ -30,8 +30,8 @@ function pp(object, indent) { } else if(typeof(object) === "object") { str += "{\n"; indent += " "; - var last = Object.getOwnPropertyNames(object).pop() - Object.getOwnPropertyNames(object).forEach(function (k) { + var last = getFields(object).pop() + getFields(object).forEach(function (k) { str += indent + k + ": "; try { str += pp(object[k], indent); @@ -63,11 +63,18 @@ function pp(object, indent) { return str; } +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; +}; + var isBigNumber = function (object) { return typeof BigNumber !== 'undefined' && object instanceof BigNumber; }; - function prettyPrint(/* */) { var args = arguments; var ret = "";