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
|
const logger = require('./logger')()
// Pulls all functions from a class and sends output to 'controller.js'
class Methods {
constructor() {
this.removeMethods = [
'scripts',
'constructor',
'__defineGetter__',
'__defineSetter__',
'hasOwnProperty',
'__lookupGetter__',
'__lookupSetter__',
'isPrototypeOf',
'propertyIsEnumerable',
'toString',
'valueOf',
'__proto__',
'toLocaleString'
]
}
GetMethods(x) {
try {
this.object = {
class: x,
props: [],
methods: new Map()
}
do {this.object.props = this.object.props.concat(Object.getOwnPropertyNames(x))} while (x = Object.getPrototypeOf(x))
this.object.props.filter((prop) => {this.object.methods.set(prop, this.object.class[prop])})
this.int = 0
for (const [key, value] of this.object.methods.entries()) {
if (this.object.methods.has(this.removeMethods[this.int])) {this.object.methods.delete(this.removeMethods[this.int])}
this.int++
}
return this.object.methods
} catch (err) {
logger.Error(err)
return false
}
}
}
module.exports = () => {return new Methods}
|