# 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)

Latest version **0.1.0** (published 2018-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install inspect-parameters-declaration
pnpm add inspect-parameters-declaration
yarn add inspect-parameters-declaration
bun add inspect-parameters-declaration
```

Provides the command `inspect-parameters-declaration`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-10-24 |
| First published | 2017-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 16.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Diego ZoracKy |
| Maintainers | diegozoracky |
| Keywords | functions, function, parameters, parameter, definitions, definition, names, default values, destrucuring, destrucure, destrucured |

## Links

- npm: https://www.npmjs.com/package/inspect-parameters-declaration
- npm.io page: https://npm.io/package/inspect-parameters-declaration

## Dependencies (4)

- [magicli](https://npm.io/package/magicli.md) 0.0.8
- [split-skip](https://npm.io/package/split-skip.md) 0.0.2
- [unpack-string](https://npm.io/package/unpack-string.md) 0.0.2
- [stringify-parameters](https://npm.io/package/stringify-parameters.md) 0.0.7

## Recent versions

- 0.1.0 (latest) — 2018-10-24
- 0.0.12 — 2017-11-09
- 0.0.11 — 2017-11-09
- 0.0.10 — 2017-09-16
- 0.0.9 — 2017-08-27
- 0.0.8 — 2017-08-27
- 0.0.7 — 2017-08-27
- 0.0.6 — 2017-08-27
- 0.0.5 — 2017-08-24
- 0.0.4 — 2017-08-24
- 0.0.3 — 2017-08-24
- 0.0.2 — 2017-08-24
- 0.0.1 — 2017-08-24

## README

# inspect-parameters-declaration

[![Build Status](https://api.travis-ci.org/DiegoZoracKy/inspect-parameters-declaration.svg)](https://travis-ci.org/DiegoZoracKy/inspect-parameters-declaration) [![npm](https://img.shields.io/npm/v/inspect-parameters-declaration.svg)]() [![npm](https://img.shields.io/npm/l/inspect-parameters-declaration.svg)]()

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
```
```bash
npx inspect-parameters-declaration --help
```

## 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} = {}, ...theArgs) => console.log("noop");

const parametersNames = getParametersNames(testFunction);
const inspectedParameters = inspectParameters(testFunction);

///////////////////////////////
// parametersNames :: RESULT //
///////////////////////////////
// [ "a", "b", "c", "d", "f", "g", "theArgs" ]


///////////////////////////////////
// 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"
//             }
//         ]
//     },
//     {
//         "parameter": "theArgs",
//         "isRestParameter": true,
//         "declaration": "...theArgs"
//     }
// ]
```

---
_Source: https://npm.io/package/inspect-parameters-declaration · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
