aboutsummaryrefslogtreecommitdiffstats
path: root/jsre/pp_js.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-09 22:19:56 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-09 22:19:56 +0800
commit78425593535ce07acf2a9d6c0e87f4e84cce137f (patch)
tree14a66c799ab212db67998810edd0f5a8a54fb3f3 /jsre/pp_js.go
parent3f4ce70d9263ff635385d694b9ac3f3c5ad8de12 (diff)
downloadgo-tangerine-78425593535ce07acf2a9d6c0e87f4e84cce137f.tar.gz
go-tangerine-78425593535ce07acf2a9d6c0e87f4e84cce137f.tar.zst
go-tangerine-78425593535ce07acf2a9d6c0e87f4e84cce137f.zip
jsre: sort pretty print output, fields before funcs
Diffstat (limited to 'jsre/pp_js.go')
-rw-r--r--jsre/pp_js.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/jsre/pp_js.go b/jsre/pp_js.go
index 4e0a04f83..e5e52b1a2 100644
--- a/jsre/pp_js.go
+++ b/jsre/pp_js.go
@@ -70,15 +70,32 @@ var redundantFields = [
];
var getFields = function (object) {
- var result = Object.getOwnPropertyNames(object);
+ var members = Object.getOwnPropertyNames(object);
if (object.constructor && object.constructor.prototype) {
- result = result.concat(Object.getOwnPropertyNames(object.constructor.prototype));
+ members = members.concat(Object.getOwnPropertyNames(object.constructor.prototype));
}
- return result.filter(function (field) {
+
+ var fields = members.filter(function (member) {
+ return !isMemberFunction(object, member)
+ }).sort()
+ var funcs = members.filter(function (member) {
+ return isMemberFunction(object, member)
+ }).sort()
+
+ var results = fields.concat(funcs);
+ return results.filter(function (field) {
return redundantFields.indexOf(field) === -1;
});
};
+var isMemberFunction = function(object, member) {
+ try {
+ return typeof(object[member]) === "function";
+ } catch(e) {
+ return false;
+ }
+}
+
var isBigNumber = function (object) {
return typeof BigNumber !== 'undefined' && object instanceof BigNumber;
};