Get function arguments, useful for and used in dependency injectors. Works for regular functions, generator functions and arrow functions.
Install
npm i get-function-arguments --save
Usage
For more use-cases see the tests
const getFunctionArguments = require('get-function-arguments')
Get function arguments names.
Params
fn
{Function}: Function from which to get arguments names.max
{Number}: How many characters to cut from fn
s toString.returns
{Array}
Example
var fnArgs = require('get-function-arguments')
console.log(fnArgs(function (a, b, c) {}))
console.log(fnArgs(function named (a , b, c) {}))
console.log(fnArgs(a => {}))
console.log(fnArgs((a, b) => {}))
console.log(fnArgs(function * (a ,b, c) {}))
console.log(fnArgs(function * named (a ,b, c) {}))
Related
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.