An open API service indexing awesome lists of open source software.

https://github.com/sebaplaza/paramsifier


https://github.com/sebaplaza/paramsifier

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# paramsifier

This library parses function and class constructor parameters.

## How to use it ?

```js
import { parseParameterList } from "paramsifier";

// With Classes
class MyClass {
constructor({ firstParam, secondParam }, thirdParam) {}
}

parseParameterList(MyClass.toString());
// [
// { name: 'firstParam', optional: false },
// { name: 'secondParam', optional: false },
// { name: 'thirdParam', optional: false }
// ]

// With Functions
function myFunction(param1, param2, param3) {}

parseParameterList(myFunction.toString());
// [
// { name: 'param1', optional: false },
// { name: 'param2', optional: false },
// { name: 'param3', optional: false }
// ]
```

## Credits

Original parser code has [been extracted](https://github.com/jeffijoe/awilix/issues/307) from [awilix](https://github.com/jeffijoe/awilix) param-parser.
Thanks @jeffijoe