is-arrow-function
is-arrow-function copied to clipboard
False positive on object methods with arrow functions inside
const isArrow = require('is-arrow-function')
const x = {
foo() {
return 42
},
bar() {
return (() => 10)()
},
buz() {
// if this was an arrow function, it would have included => in it
return 123
},
}
console.log(x.foo(), x.bar(), x.buz())
console.log(isArrow(x.foo))
console.log(isArrow(x.bar)) // fail
console.log(isArrow(x.buz)) // fail
This feels similar to #15 - short of including an actual JS parser, I'm not sure how to reliably handle cases like these.