goatslacker / get-parameter-names

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

Fails with nested fat arrow functions #5

Open SomeKittens opened 8 years ago

SomeKittens commented 8 years ago

Input:

a => {
  return new Promise((resolve, reject) => {
    setTimeout(() => resolve(a * 2), 500);
  });
}

Expected output:

['a']

Output:

[ '(resolve', 'reject' ]

Other things I tried that broke:

a => {
  setTimeout(() => resolve(a * 2), 500);
}

Output: [ '(' ]

a => {
  return new Promise(resolve => {
    setTimeout(() => resolve(a * 2), 500);
  });
}

Output: [ 'resolve', 'setTimeout((' ]

a => {
  return new Promise(resolve => {
  });
}

Output: [ 'resolve', '}' ]

$ node -v
v5.9.1
CaptEmulation commented 8 years ago

Should be fixed by PR #7