Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inspect-parameters-declaration

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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)

  • 0.0.2
  • npm
  • Socket score

Version published
Weekly downloads
152K
increased by2.54%
Maintainers
1
Weekly downloads
 
Created
Source

inspect-parameters-declaration

Build Status npm npm

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

npm install inspect-parameters-declaration

CLI

npm install inspect-parameters-declaration -g

Usage

inspectParameters(source); getAllParametersNames(source);

Where 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} = {}')

const { getAllParametersNames, inspectParameters } = require('inspect-parameters-declaration');

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

const allParametersNames = getAllParametersNames(testFunction);
const inspectedParameters = inspectParameters(testFunction);

//////////////////////////////////////
// allParametersNames :: 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"           //
//             }                                //
//         ]                                    //
//     }                                        //
// ]                                            //
//////////////////////////////////////////////////

Keywords

FAQs

Package last updated on 24 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc