-
Notifications
You must be signed in to change notification settings - Fork 0
/
varinfosnip.js
52 lines (48 loc) · 1.84 KB
/
varinfosnip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const _my_distinct___path = require('path');
const _m_y_distinct__writedata = require(_my_distinct___path.join(process.env.MFUZZERLIB,"utils")).writedata;
var varIntroSet = {};
var varIntrospect = (objname, obj) => {
var attrs = {};
var methods = new Set();
if(obj==undefined || obj==null){
return;
}
var enumerableProperties = Array.isArray(obj) ? Object.keys(obj) : null;
Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).forEach((name) => {
try{
if (typeof obj[name] === 'function') {
methods.add(name);
} else if (obj.hasOwnProperty(name) && attrs[name] === undefined) {
if(name in obj && constructor in obj[name] && name in obj[name].constructor)
attrs[name] = obj[name].constructor.name;
}
}catch(err){
null;
}
});
Object.getOwnPropertyNames(obj).forEach((name) => {
try{
if (enumerableProperties !== null && enumerableProperties.indexOf(name) !== -1) {
return;
}
if (typeof obj[name] === 'function') {
methods.add(name);
} else if (obj.hasOwnProperty(name) && attrs[name] === undefined) {
if(name in obj && constructor in obj[name] && name in obj[name].constructor)
attrs[name] = obj[name].constructor.name;
}
}catch(err){
null;
}
});
var objtype = obj.constructor.name;
if(objtype == 'String'){
for(var index in attrs){
var attr = attrs[index];
if(!isNaN(parseInt(index)) && attr == 'String'){
delete attrs[index];
}
}
}
return {'obj':objname, 'objtype':objtype, 'methods':methods, 'attrs':attrs};
};