get-parameter-names icon indicating copy to clipboard operation
get-parameter-names copied to clipboard

Fails with variable definitions

Open maxgherman opened this issue 8 years ago • 4 comments

Input:

c => { let test2 = c.resolve(); return new Test3(test2); } Expected output:

['c']

Output:

[ 'c', 'let', 'test2' ]

Input:

c => { var test2 = c.resolve(); return new Test3(test2); } Expected output:

['c']

Output:

[ 'c', 'var', 'test2' ]

$ node -v v4.2.1

maxgherman avatar Apr 14 '16 13:04 maxgherman

I think the problem is when you use a fat-arrow function with 1 argument and the argument is not defined with parenthesis.

jfromaniello avatar Jun 27 '16 16:06 jfromaniello

Use my scoped package: https://www.npmjs.com/package/@avejidah/get-parameter-names There are other issues that are fixed there as well.

benbotto avatar Jul 29 '16 22:07 benbotto

With function definition:

function test(arg1=3, /*arg2,*/ arg3='duh') { console.log(arguments); }

getParameterNames(test) returns ["arg1", "arg"].

Here is another test:

function test(arg1=3, /*arg2,*/ arg345='duh') { console.log(arguments); }

getParameterNames(test) returns ["arg1", "arg34"].

It seems that it works really well EXCEPT for the very last argument, on which it strips the last character for some reason. Hope this helps. Oh, and the tests were run in the chrome browser console window.

troywweber7 avatar Sep 12 '16 20:09 troywweber7

@troywweber7 These tests pass correctly in my fork, and my fork has a number of other issues corrected. Use my scoped module, as described in my comment above (npm install @avejidah/get-parameter-names).

benbotto avatar Sep 13 '16 03:09 benbotto