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 - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

6

lib/inspect-parameters-declaration.js

@@ -43,2 +43,8 @@ 'use strict';

const isRestParameter = parameterSpec.parameter.match(/^\.{3}/);
if (isRestParameter) {
parameterSpec.parameter = parameterSpec.parameter.replace(/^\.{3}/, '');
parameterSpec.isRestParameter = true;
}
parameterSpec.declaration = param;

@@ -45,0 +51,0 @@ return parameterSpec;

2

package.json
{
"name": "inspect-parameters-declaration",
"version": "0.0.9",
"version": "0.0.10",
"description": "Inspects function's parameters declaration and returns information about it (e.g. names, default values, if needs destructuring, destructured parameters names and default values)",

@@ -5,0 +5,0 @@ "main": "./lib/inspect-parameters-declaration.js",

@@ -33,3 +33,3 @@ # inspect-parameters-declaration

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

@@ -42,3 +42,3 @@ const parametersNames = getParametersNames(testFunction);

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

@@ -83,4 +83,9 @@

// ]
// },
// {
// "parameter": "theArgs",
// "isRestParameter": true,
// "declaration": "...theArgs"
// }
// ]
```

@@ -66,5 +66,5 @@ 'use strict';

functionExpectingDestructuring: {
input: function fn({ a } = {}, b, [d, e, z = "ZZ"] = [1, 2]) {},
expectedResult: ['a', 'b', 'd', 'e', 'z']
functionExpectingDestructuringPlusRestParameter: {
input: function fn({ a } = {}, b, [d, e, z = "ZZ"] = [1, 2], ...aRestParameter) {},
expectedResult: ['a', 'b', 'd', 'e', 'z', 'aRestParameter']
},

@@ -174,3 +174,3 @@

functionMultipleParametersDeclaration: {
input: ([p1 = 1,[p2 = 'P2DEF',[p3]]]=[], [a,b], { z, k, zk: {zz} }={}, zkzkz = 111, [zk,zzk,zzzk],iowu) => {},
input: ([p1 = 1,[p2 = 'P2DEF',[p3]]]=[], [a,b], { z, k, zk: {zz} }={}, zkzkz = 111, [zk,zzk,zzzk],iowu, ...aRestParameter) => {},
expectedResult: [{

@@ -240,2 +240,6 @@ "parameter": "[p1 = 1,[p2 = 'P2DEF',[p3]]]",

"declaration": "iowu"
}, {
"parameter": "aRestParameter",
"isRestParameter": true,
"declaration": "...aRestParameter"
}]

@@ -271,20 +275,16 @@ },

expectedResult: [{
"parameter": "[p1,[p2 = '',[p3]]]",
"defaultValue": "[]",
"expectsDestructuring": true,
"declaration": "[p1,[p2 = '',[p3]]]=[]",
"destructuredParameters": [
{
"parameter": "p1",
"declaration": "p1"
},
{
"parameter": "p2",
"declaration": "p2 = ''"
},
{
"parameter": "p3",
"declaration": "p3"
}
]
"parameter": "[p1,[p2 = '',[p3]]]",
"defaultValue": "[]",
"expectsDestructuring": true,
"declaration": "[p1,[p2 = '',[p3]]]=[]",
"destructuredParameters": [{
"parameter": "p1",
"declaration": "p1"
}, {
"parameter": "p2",
"declaration": "p2 = ''"
}, {
"parameter": "p3",
"declaration": "p3"
}]
}]

@@ -291,0 +291,0 @@ }

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