goatslacker / get-parameter-names

Retrieves the argument names of a function
46 stars 13 forks source link

fix bug when function like as 'f(id = 1)' #12

Open Rwing opened 7 years ago

Rwing commented 7 years ago
function f(id = 1){
    id = 'a,b';
}

getParameterNames(f); // => [ 'id', 'b\';' ]
Rwing commented 7 years ago

@goatslacker Hi, please help me to review it~

CaptEmulation commented 7 years ago

Can you write a unit test to demonstrate this failure? Bonus points if you can also get this function to parse: ( a = 1 , b=2, c = (err, data)=>{}) => {}

CaptEmulation commented 7 years ago

Just FYI that CaptEmulation/get-parameter-names handles this case. npm i @captemulation/get-parameter-names