diff options
Diffstat (limited to 'source/method.js')
| -rw-r--r-- | source/method.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source/method.js b/source/method.js new file mode 100644 index 0000000..af71cec --- /dev/null +++ b/source/method.js @@ -0,0 +1,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} |
