Skip to content

alesmenzel/function-arguments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Function arguments

Parses function arguments and returns an array of parameter names. Uses AST parser acorn and can handle functions with default parameters.

Instalation

npm i @alesmenzel/function-arguments

Usage

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"]

About

Parses function arguments ๐Ÿ“

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published