1.0.0 • Published 8 years ago

get-function-arguments v1.0.0

Weekly downloads
1,230
License
MIT
Repository
github
Last release
8 years ago

get-function-arguments npmjs.com The MIT License

Get function arguments, useful for and used in dependency injectors. Works for regular functions, generator functions and arrow functions.

code climate standard code style travis build status coverage status dependency status

Install

npm i get-function-arguments --save

Usage

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 from fns 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

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.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github