is-async-function
is-async-function copied to clipboard
False positives for any function named "async" in classes or object literals
isAsyncFunction will return true for both (class { async () {} }).prototype.async and { async () {} }.async. The cause is that keywords are allowed to be used as function/getter/setter names in classes and object literals, which the module is-async-function does not take into account.
@melab
It's allowed but it's a bad practice, it's just a legacy pre async javascript.
Also, you may try parse-function, it uses full-fledged parsers, so there are no errors like this.
parseFunction(fn)
// result.isArrow
// result.isAsync
// result.isNamed
// result.isAnonymous
// result.isGenerator
// result.isExpression
@Melab
It's allowed but it's a bad practice, it's just a legacy pre async javascript.
Also, you may try
parse-function, it uses full-fledged parsers, so there are no errors like this.parseFunction(fn) // result.isArrow // result.isAsync // result.isNamed // result.isAnonymous // result.isGenerator // result.isExpression
Of course it's allowed. I wouldn't have been able to test isAsyncFunction on it if it were invalid. I am just reporting this false positive to this project as a courtesy so that it may be fixed.