-
Notifications
You must be signed in to change notification settings - Fork 4
/
getjsprops.js
39 lines (39 loc) · 1.01 KB
/
getjsprops.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
var _ = function() {
var removeDups = function(arr) {
for (var i = 0; i < arr.length; i++) {
var lastIndex;
while ((lastIndex = arr.lastIndexOf(arr[i])) !== i) {
arr.splice(lastIndex, 1);
}
}
return arr;
};
var getAllKeys = function(obj) {
var _ret = Object.keys(obj).concat(Object.getOwnPropertyNames(obj));
for (var key in obj) {
_ret.push(key);
}
_ret = _ret.map(function(e) {
if (typeof obj[e] === 'function') {
return e + '(';
}
return e;
});
if (obj.hasOwnProperty('prototype')) {
_ret = _ret.concat(getAllKeys(obj.prototype));
}
return _ret;
};
var roots = Array.prototype.slice.call(arguments);
var _ret = [];
for (var i = 0; i < roots.length; i++) {
_ret = _ret.concat(removeDups(getAllKeys(roots[i])));
}
_ret = removeDups(_ret
.filter(function(e) {
return e.charAt(0) !== '_' && e.charAt(0) !== '$';
})
.sort());
console.log(_ret);
copy('[\'' + _ret.join('\', \'') + '\']');
};