aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-04-02 17:35:01 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-04-02 17:35:01 +0800
commit7e13ee602e003ad2a3db6d822d24f220f23d632e (patch)
tree443f191cc03ff8fa84b0672bb55e3d24509c113f
parentb8124ec79182dbf90b28c8527f2440cea6473f1b (diff)
parentf960fc066e2daa27658e61e2b5da381c31bfff15 (diff)
downloaddexon-7e13ee602e003ad2a3db6d822d24f220f23d632e.tar.gz
dexon-7e13ee602e003ad2a3db6d822d24f220f23d632e.tar.zst
dexon-7e13ee602e003ad2a3db6d822d24f220f23d632e.zip
Merge pull request #625 from debris/nonenumerable
print nonenumerable properties of object in geth console && proper printing BigNumbers
-rw-r--r--jsre/pp_js.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/jsre/pp_js.go b/jsre/pp_js.go
index 3352f23ce..0b22afe6d 100644
--- a/jsre/pp_js.go
+++ b/jsre/pp_js.go
@@ -23,18 +23,28 @@ function pp(object, indent) {
}
}
str += " ]";
+ } else if (object instanceof Error) {
+ str += "\033[31m" + "Error";
+ } else if (isBigNumber(object)) {
+ str += "\033[32m'" + object.toString(10) + "'";
} else if(typeof(object) === "object") {
str += "{\n";
- indent += " ";
- var last = Object.keys(object).pop()
- for(var k in object) {
- str += indent + k + ": " + pp(object[k], indent);
+ indent += " ";
+ var last = Object.getOwnPropertyNames(object).pop()
+ Object.getOwnPropertyNames(object).forEach(function (k) {
+ str += indent + k + ": ";
+ try {
+ str += pp(object[k], indent);
+ } catch (e) {
+ str += pp(e, indent);
+ }
if(k !== last) {
str += ",";
}
- str += "\n";
- }
+
+ str += "\n";
+ });
str += indent.substr(2, indent.length) + "}";
} else if(typeof(object) === "string") {
str += "\033[32m'" + object + "'";
@@ -43,7 +53,7 @@ function pp(object, indent) {
} else if(typeof(object) === "number") {
str += "\033[31m" + object;
} else if(typeof(object) === "function") {
- str += "\033[35m[Function]";
+ str += "\033[35m[Function]";
} else {
str += object;
}
@@ -53,6 +63,11 @@ function pp(object, indent) {
return str;
}
+var isBigNumber = function (object) {
+ return typeof BigNumber !== 'undefined' && object instanceof BigNumber;
+};
+
+
function prettyPrint(/* */) {
var args = arguments;
var ret = "";