inspect-parameters-declaration
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -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; |
{ | ||
"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 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15938
418
88