get-function-params
v2.0.7
Published
Get list of function params, including default values (if any)
Downloads
1,103
Maintainers
Readme
get-function-params
Get list of function params, including default values (if any).
Installation
npm i get-function-params -S
Usage
const getParams = require('get-function-params')
// returns [{ param: 'a' }, { param: 'b' }, { param: 'c' }]
getParams(function(a, b, c) {})
// strips out inline comments
// returns [{ param: 'a' }, { param: 'b' }, { param: 'c' }]
getParams(function(a, b, /* bork */ c) {})
// supports arrow functions
// returns [{ param: 'a' }, { param: 'b' }, { param: 'c' }]
getParams((a, b, c) => {})
// supports default values
// returns [{ param: 'a' }, { param: 'b', default: true }]
getParams((a, b=true) => {})