diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-04-04 19:24:21 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-04-04 19:24:21 +0800 |
commit | 47298264663a563b34ebb8a1faf9fb8326fdef01 (patch) | |
tree | a8d42be85553fbb057cc47356d85cfea24d6832b /jsre/pp_js.go | |
parent | 3e042317adc99438d6ffde0cbde4f0b40ad579c1 (diff) | |
parent | bc5528b165e48e223c9c38dc1355511014c97e34 (diff) | |
download | dexon-47298264663a563b34ebb8a1faf9fb8326fdef01.tar dexon-47298264663a563b34ebb8a1faf9fb8326fdef01.tar.gz dexon-47298264663a563b34ebb8a1faf9fb8326fdef01.tar.bz2 dexon-47298264663a563b34ebb8a1faf9fb8326fdef01.tar.lz dexon-47298264663a563b34ebb8a1faf9fb8326fdef01.tar.xz dexon-47298264663a563b34ebb8a1faf9fb8326fdef01.tar.zst dexon-47298264663a563b34ebb8a1faf9fb8326fdef01.zip |
Merge branch 'develop' into rpcfabian
Diffstat (limited to 'jsre/pp_js.go')
-rw-r--r-- | jsre/pp_js.go | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/jsre/pp_js.go b/jsre/pp_js.go index 0b22afe6d..2badb90e7 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,30 @@ 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.filter(function (field) { + return redundantFields.indexOf(field) === -1; + }); +}; + var isBigNumber = function (object) { return typeof BigNumber !== 'undefined' && object instanceof BigNumber; }; - function prettyPrint(/* */) { var args = arguments; var ret = ""; |