Socket
Socket
Sign inDemoInstall

function-arguments

Package Overview
Dependencies
0
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-arguments

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


Version published
Maintainers
2
Weekly downloads
14,653
increased by21.25%

Weekly downloads

Readme

Source

function-arguments npm version github release License

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

code style linux build code coverage dependency status npm downloads paypal donate

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 = require('function-arguments')

API

functionArguments

Get function arguments names.

Params

  • fn {Function}: Function from which to get arguments names.
  • returns {Array}

Example

var fnArgs = require('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' ]

Works when using comments

As it works for ES2015, it also works if you use comments in weird places.

console.log(fnArgs(function /* something may */ (
  // go,
  go,
  /* wrong, */
  here
  // (when, using, comments) {}
) { return 1 })) // => [ 'go', 'here' ]

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

Keywords

FAQs

Last updated on 15 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc