Open
Description
For instance, if a default parameter value uses a function:
const isArrow = require("is-arrow-function");
const arrow = (a = Math.random(10)) => {};
console.log(isArrow(arrow)); // false, should be true
There are lots of ways to include a )
in the parameter list. For instance, (a, b = (a)) => {}
(but who would write that? ... you know someone would :-) ).
Sadly, I think the only way to deal with this would be to fire up a full parser, since a default can be anything, including a function definition with arbitrary code in it:
const isArrow = require("is-arrow-function");
const arrow = (a = function() {
if (Math.random() < 0.5) {
return 42;
}
return "something else";
}) => a();
console.log(isArrow(arrow)); // false, should be true
Metadata
Metadata
Assignees
Labels
No labels