# inspect-function

> Inspects a function and returns informations about it (e.g. name, parameters names, parameters and default values, signature)

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

## Install

```sh
npm install inspect-function
pnpm add inspect-function
yarn add inspect-function
bun add inspect-function
```

Provides the command `inspect-function`.

## 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.4.0 |
| Published | 2018-10-24 |
| First published | 2017-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Diego ZoracKy |
| Maintainers | diegozoracky |
| Keywords | function, inspect, params, signature, parameters, arguments, jsdocs, docs |

## Links

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

## Dependencies (5)

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

## Recent versions

- 0.4.0 (latest) — 2018-10-24
- 0.3.4 — 2017-11-09
- 0.3.3 — 2017-11-09
- 0.3.1 — 2017-08-27
- 0.3.0 — 2017-08-27
- 0.2.2 — 2017-05-28
- 0.2.1 — 2017-05-08
- 0.2.0 — 2017-05-08
- 0.1.2 — 2017-05-08
- 0.1.1 — 2017-05-07
- 0.1.0 — 2017-05-07

## README

# inspect-function

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

Inspects a function and returns informations about it (e.g. name, parameters names, parameters and default values, signature).
Useful when creating automated tasks, e.g., docs generations.

## Installation

```bash
npm install inspect-function
```
**CLI**
```bash
npm install inspect-function -g
```
```bash
npx inspect-function --help
```

## Usage

`inspectFunction(fn, name);`

```javascript
// The module
const inspectFunction = require('inspect-function');

// A function
const testFunction = (a = 'z', b = [1,2,3], c, {d,e: {f}, g} = {}) => console.log('noop');

// Inspects
const result = inspectFunction(testFunction);

////////////////////////
// `result` will be:  //
////////////////////////
{
    "name": "testFunction",
    "signature": "testFunction(a = 'z', b = [1,2,3], c, {d,e: {f}, g} = {});",
    "parameters": [
        {
            "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"
                }
            ]
        }
    ],
    "parametersNames": [
        "a",
        "b",
        "c",
        "d",
        "f",
        "g"
    ]
}
```

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