Get arguments of a function, useful for and used in dependency injectors. Works for regular functions, generator functions and arrow functions.
Install
Install with npm
$ npm i function-arguments --save
Important: for more advanced stuff please use parse-function, don't suggest features or complex bugs.
Usage
For more use-cases see the tests
const functionArguments =
API
functionArguments
Get function arguments names.
Params
fn
{Function}: Function from which to get arguments names.returns
{Array}
Example
var fnArgs = console // => [ 'a', 'b', 'c' ]console // => [ 'a', 'b', 'c' ] console // => [ 'a' ]console // => [ 'a', 'b' ] console // => [ 'a', 'b', 'c' ]console // => [ 'a', 'b', 'c' ]
Works when using comments
As it works for ES2015, it also works if you use comments in weird places.
console // => [ 'go', 'here' ]
Related
- flatten-arguments: Fastest, simplest and smallest. Pass
arguments
object or list of… more | homepage - fn-args: Get the arguments of a function | homepage
- fn-name: Get the name of a named function | homepage
- get-fn-name: Get function name with strictness and correctness in mind. Also… more | homepage
- handle-arguments: Get separately non-callback arguments in
.arguments
and the last argument… more | homepage - manage-arguments: Prevents arguments leakage - managing arguments. From Optimization killers by… more | homepage
- parse-function: Parse a function, arrow function or string to object with… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. But before doing anything, please read the CONTRIBUTING.md guidelines.