(fn: Function)
| 19 | const COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm; |
| 20 | const ARR = /=>.*$/gm; |
| 21 | function parseParameters(fn: Function) { |
| 22 | const code = fn.toString() |
| 23 | .replace(COMMENTS, '') |
| 24 | .replace(ARR, ''); |
| 25 | const result = code.slice(code.indexOf('(') + 1, code.indexOf(')')) |
| 26 | .match(/([^,]+)/g)?.map((i) => i.trim()); |
| 27 | return result ?? []; |
| 28 | } |
| 29 | |
| 30 | async function runScript(name: string, arg: any) { |
| 31 | const s = global.Hydro.script[name]; |