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.5 to 0.0.6

35

lib/inspect-parameters-declaration.js

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

const isArrayLike = p => p.match(/^\[+/) || null;
const isObjectLike = p => p.match(/^{+/) || null;
const matchObjectProperty = p => p.match(/^([^{]+):(.*)/) || null;
const isArrayLike = p => p.match(/^\[+/);
const isObjectLike = p => p.match(/^{+/);
const matchObjectProperty = p => p.match(/^([^{]+):(.*)/);

@@ -62,9 +62,6 @@ function splitSkipBrackets(string, delimiter) {

parametersArray.forEach(param => {
if (isArrayLike(param)) {
return destructureParametersFromArray(param, parameters);
if (isArrayLike(param) || isObjectLike(param)) {
return destructureParameter(param, parameters);
}
// const { parameter, defaultValue, declaration } = getParameterSpec(param);
// parameters.push({ parameter, defaultValue, declaration });
parameters.push(getParameterSpec(param));

@@ -83,10 +80,8 @@ });

let [, key, value] = objectProperty.map(v => v.trim());
if (isObjectLike(value)) {
return destructureParametersFromObject(value, parameters);
if (isArrayLike(value) || isObjectLike(value)) {
return destructureParameter(value, parameters);
}
}
// const { parameter, defaultValue, declaration } = getParameterSpec(param);
// parameters.push({ parameter, defaultValue, declaration });
parameters.push(getParameterSpec(param));

@@ -98,2 +93,12 @@ });

function destructureParameter(parameter, parameters) {
if (isArrayLike(parameter)) {
return destructureParametersFromArray(parameter, parameters);
}
if (isObjectLike(parameter)) {
return destructureParametersFromObject(parameter, parameters);
}
}
function destructureParameters(param) {

@@ -131,6 +136,2 @@ const parametersArray = getParametersArray(param);

if(!parametersArray || parametersArray.length === 1){
return inspectParameterFromString(parameters);
}
const inspectedParameters = parametersArray.reduce((result, parameter) => {

@@ -137,0 +138,0 @@ const parameterSpec = inspectParameterFromString(parameter);

{
"name": "inspect-parameters-declaration",
"version": "0.0.5",
"version": "0.0.6",
"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",

@@ -243,3 +243,3 @@ 'use strict';

input: `[p1,[p2 = '',[p3]]]=[]`,
expectedResult: {
expectedResult: [{
"parameter": "[p1,[p2 = '',[p3]]]",

@@ -263,3 +263,3 @@ "defaultValue": "[]",

]
}
}]
},

@@ -269,3 +269,3 @@

input: function ([p1,[p2 = '',[p3]]]=[]) { return; },
expectedResult: {
expectedResult: [{
"parameter": "[p1,[p2 = '',[p3]]]",

@@ -289,3 +289,3 @@ "defaultValue": "[]",

]
}
}]
}

@@ -292,0 +292,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