get-function-arguments
v1.0.0
Published
Get function arguments, useful for and used in dependency injectors. Works for regular functions, generator functions and arrow functions.
Maintainers
Readme
get-function-arguments

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 --saveUsage
For more use-cases see the tests
const getFunctionArguments = require('get-function-arguments')getFunctionArguments
Get function arguments names.
Params
fn{Function}: Function from which to get arguments names.max{Number}: How many characters to cut fromfns toString.returns{Array}
Example
var fnArgs = require('get-function-arguments')
console.log(fnArgs(function (a, b, c) {})) // => [ 'a', 'b', 'c' ]
console.log(fnArgs(function named (a , b, c) {})) // => [ 'a', 'b', 'c' ]
console.log(fnArgs(a => {})) // => [ 'a' ]
console.log(fnArgs((a, b) => {})) // => [ 'a', 'b' ]
console.log(fnArgs(function * (a ,b, c) {})) // => [ 'a', 'b', 'c' ]
console.log(fnArgs(function * named (a ,b, c) {})) // => [ 'a', 'b', 'c' ]Related
- flatten-arguments: Fastest, simplest and smallest. Pass
argumentsobject or list of… more | homepage - fn-name: Get the name of a named function | homepage
- function-arguments: Get function arguments, useful for and used in dependency injectors.… more | homepage
- get-fn-name: Get function name with strictness and correctness in mind. Also… more | homepage
- handle-arguments: Handles given Arguments object - return separatly last argument (commonly… 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.
