Closed chocolateboy closed 9 years ago
There's also function*
(ES6) and async function
(ES7).
IMHO this qualifies for a different regex. like es6-function-regex
technically this shouldn't even be called "function-regex" since it's not. It should be more specific, like: https://github.com/jonschlinkert/parse-code-context/blob/master/index.js#L14-L33
IMHO this qualifies for a different regex. like es6-function-regex
I agree that this is probably out of scope for this package.
But, come to think of it, a regex will never be able to handle destructured parameters in the general case, since regular languages don't support balanced delimiters.
https://github.com/jonschlinkert/parse-code-context/blob/master/index.js#L14-L33
FYI: that regex shares several issues with this regex and adds at least one new issue e.g. it doesn't handle:
function foo () {} // > 1 space
or:
function // newline
foo () {}
Yea, I think it should go to something like es6-function-regex
because we should also handle arrow functions?
Closing this, since — as mentioned — a regex can't handle all ES6 function syntax (e.g. destructuring).
Various ES6 features are unsupported e.g.:
test
output