This library parses function and class constructor parameters.
import { parseParameterList } from "paramsifier";
// With Classes
class MyClass {
constructor({ firstParam, secondParam }, thirdParam) {}
}
parseParameterList(MyClass.toString());
// [
// { name: 'firstParam', optional: false },
// { name: 'secondParam', optional: false },
// { name: 'thirdParam', optional: false }
// ]
// With Functions
function myFunction(param1, param2, param3) {}
parseParameterList(myFunction.toString());
// [
// { name: 'param1', optional: false },
// { name: 'param2', optional: false },
// { name: 'param3', optional: false }
// ]
Original parsed code has been extracted from awilix param-parser. Thanks @jeffijoe
Thanks @