Socket
Socket
Sign inDemoInstall

function-arguments

Package Overview
Dependencies
1
Maintainers
1
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
1
Created

Changelog

Source

1.0.1 - 2016-03-18

  • Release v1.0.1 / npm@v1.0.1
  • update docs
  • make it works when using comments
  • return earlier if not arguments
  • update description

Readme

Source

function-arguments npmjs.com The MIT License

Get arguments of a function, 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 function-arguments --save

Usage

For more use-cases see the tests

const functionArguments = require('function-arguments')

functionArguments

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('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 18 Mar 2016

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