File size: 459 Bytes
6242a59 |
1 2 3 4 5 6 7 8 9 10 11 12 |
export const extractArgs = (func: (...args: any[]) => any) => {
return (func + '')
.replace(/[/][/].*$/gm, '') // strip single-line comments
.replace(/\s+/g, '') // strip white space
.replace(/[/][*][^/*]*[*][/]/g, '') // strip multi-line comments
.split('){', 1)[0]
.replace(/^[^(]*[(]/, '') // extract the parameters
.replace(/=[^,]+/g, '') // strip any ES6 defaults
.split(',')
.filter(Boolean); // split & filter [""]
};
|