@captemulation/get-parameter-names

Retrieves parameter names from a function

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
70Nov 29, 2020Jun 26, 2016Minified + gzip package size for @captemulation/get-parameter-names in KB

Readme

get-parameter-names

Retrieves the argument names of a function

Install

npm install @captemulation/get-parameter-names

Usage

function foo(bar, baz) {
  return bar + baz
}

var get = require('@captemulation/get-parameter-names')
get(foo) // = ['bar', 'baz']

Also supports fat arrow and default functions

const foo = (a, b = 20) => a + b

var get = require('@captemulation/get-parameter-names')
get(foo) // = ['a', 'b']

Also supports ES6 async functions

async function foo(a, b) { return a + b }

var get = require('@captemulation/get-parameter-names')
get(foo) // = ['a', 'b']

Also supports ES6 Class constructors


var get = require('@captemulation/get-parameter-names')

class Animal{
  constructor(){}
}
class Cat extends Animal{
  constructor(a, b){
    super();
    get(this.constructor) // = ['a', 'b']
  }
}

get(Cat) // = ['a', 'b']

Tests

npm test

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.