print nonenumerable properties of object in geth console

This commit is contained in:
Marek Kotewicz 2015-04-02 01:53:33 +02:00
parent b8124ec791
commit bb3ae3026e
1 changed files with 15 additions and 7 deletions

View File

@ -23,18 +23,26 @@ function pp(object, indent) {
} }
} }
str += " ]"; str += " ]";
} else if (object instanceof Error) {
str += "\033[31m" + "Error";
} else if(typeof(object) === "object") { } else if(typeof(object) === "object") {
str += "{\n"; str += "{\n";
indent += " "; indent += " ";
var last = Object.keys(object).pop() var last = Object.getOwnPropertyNames(object).pop()
for(var k in object) { Object.getOwnPropertyNames(object).forEach(function (k) {
str += indent + k + ": " + pp(object[k], indent); str += indent + k + ": ";
try {
str += pp(object[k], indent);
} catch (e) {
str += pp(e, indent);
}
if(k !== last) { if(k !== last) {
str += ","; str += ",";
} }
str += "\n"; str += "\n";
} });
str += indent.substr(2, indent.length) + "}"; str += indent.substr(2, indent.length) + "}";
} else if(typeof(object) === "string") { } else if(typeof(object) === "string") {
str += "\033[32m'" + object + "'"; str += "\033[32m'" + object + "'";