Détail du package

function-arguments

tunnckoCore57kMIT1.0.9

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

args, arguments, arrow, arrow-function

readme

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' ]

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

changelog

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.0.9 (2020-01-15)

Bug Fixes

  • add funding + note for parse-function (0e0d074)
  • add type files to distributed package (2a7c839)
  • add TypeScript files - index.d.ts (#11) (8619796)

1.0.8 (2016-10-29)

Bug Fixes

  • docs: params before examples (0fd3a4c)

1.0.7 (2016-10-27)

Bug Fixes

1.0.6 - 2016-09-21

  • Release v1.0.6 / npm@v1.0.6
  • add coveralls to devDeps, closes #4

1.0.5 - 2016-09-21

  • Release v1.0.5 / npm@v1.0.5
  • move arr-map require outside of the module.exported function, closes #3
  • update to use mukla instead of assertit
  • update npm scripts
  • update travis builds and coverage things
  • update gitignore
  • add standard and nyc to devDeps

1.0.4 - 2016-03-18

  • Release v1.0.4 / npm@v1.0.4
  • update docs
  • bugfix: problems with regex, slicing and max option
  • drop max option - no breaking change

1.0.3 - 2016-03-18

  • Release v1.0.3 / npm@v1.0.3
  • fix options.max problems, make some checks and defaults

1.0.2 - 2016-03-18

  • Release v1.0.2 / npm@v1.0.2
  • fix: if max bigger than fn.toString().length, causing strange bugs in relike?

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

1.0.0 - 2016-03-18

  • Release v1.0.0 / npm@v1.0.0
  • implement :cat2:

0.0.0 - 2016-03-18

  • Initial commit