Dia antes primera install
This commit is contained in:
83
node_modules/inspect-parameters-declaration/README.md
generated
vendored
Normal file
83
node_modules/inspect-parameters-declaration/README.md
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
# inspect-parameters-declaration
|
||||
|
||||
[](https://travis-ci.org/DiegoZoracKy/inspect-parameters-declaration) []() []()
|
||||
|
||||
Inspects function's parameters declaration and returns information about it (e.g. names, default values, if needs destructuring, destructured parameters names and default values).
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install inspect-parameters-declaration
|
||||
```
|
||||
|
||||
**CLI**
|
||||
```bash
|
||||
npm install inspect-parameters-declaration -g
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`inspectParameters(source);`
|
||||
|
||||
`getParametersNames(source);`
|
||||
|
||||
* **source** is a *function* reference or a string containing the parameters declaration (e.g. 'a = "z, b = [1,2,3], c, {d,e: {f}, g} = {}')
|
||||
|
||||
`getParametersNamesFromInspection(inspectedParameters);`
|
||||
|
||||
* **inspectedParameters** expects the result from `inspectParameters(source)`;
|
||||
|
||||
```javascript
|
||||
const { getParametersNames, inspectParameters } = require('inspect-parameters-declaration');
|
||||
|
||||
const testFunction = (a = "z", b = [1,2,3], c, {d,e: {f}, g} = {}) => console.log("noop");
|
||||
|
||||
const parametersNames = getParametersNames(testFunction);
|
||||
const inspectedParameters = inspectParameters(testFunction);
|
||||
|
||||
///////////////////////////////
|
||||
// parametersNames :: RESULT //
|
||||
///////////////////////////////
|
||||
// [ "a", "b", "c", "d", "f", "g" ]
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// inspectedParameters :: RESULT //
|
||||
///////////////////////////////////
|
||||
// [
|
||||
// {
|
||||
// "parameter": "a",
|
||||
// "defaultValue": "z",
|
||||
// "declaration": "a = \"z\""
|
||||
// },
|
||||
// {
|
||||
// "parameter": "b",
|
||||
// "defaultValue": "[1,2,3]",
|
||||
// "declaration": "b = [1,2,3]"
|
||||
// },
|
||||
// {
|
||||
// "parameter": "c",
|
||||
// "declaration": "c"
|
||||
// },
|
||||
// {
|
||||
// "parameter": "{d,e: {f}, g}",
|
||||
// "defaultValue": "{}",
|
||||
// "expectsDestructuring": true,
|
||||
// "declaration": "{d,e: {f}, g} = {}",
|
||||
// "destructuredParameters": [
|
||||
// {
|
||||
// "parameter": "d",
|
||||
// "declaration": "d"
|
||||
// },
|
||||
// {
|
||||
// "parameter": "f",
|
||||
// "declaration": "f"
|
||||
// },
|
||||
// {
|
||||
// "parameter": "g",
|
||||
// "declaration": "g"
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// ]
|
||||
```
|
||||
Reference in New Issue
Block a user