get-function-params

Get list of function params, including default values (if any)

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
get-function-params
112.0.74 years ago6 years agoMinified + gzip package size for get-function-params in KB

Readme

get-function-params npm version
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) => {})