Parses function arguments and returns an array of parameter names. Uses AST parser acorn and can handle functions with default parameters.
npm i @alesmenzel/function-arguments
Can parse ES5 named and unamed functions as well as ES6 arrow funtions and shorthand arrow functions.
const functionArguments = require('@alesmenzel/function-arguments');
// ES5
const subject = function x(a, b, c) {};
functionArguments(subject);
// ["a", "b", "c"]
// ES6
const subject = (a, b = 15, c) => {};
functionArguments(subject);
// ["a", "b", "c"]
// ES6 shorthand
const subject = a => a;
functionArguments(subject);
// ["a"]