-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async function support #24
Conversation
also, we were thinking about exposing options object as second argument, or something like that, because it's edge case and most may want to know is it genfn or normal (no matter async or not) right, @jonschlinkert? |
I haven't decided on the best way to handle this. We can't merge this PR though, as it would break a lot of code. I'm leaning towards exposing another method for this. |
Maybe you could add "hooks" support? That would not break existing code and would work great. kindOf(2);
kindOf.register(function a(b) { if(isAsyncFunction(b)) return `AsyncFunction`; return false; }); Sort of thing, if a hook returns false, the check does not stop. |
I'll submit a PR with the hooks support. |
Boom. See what you think! |
return isGeneratorFn(val) ? 'generatorfunction' : 'function'; | ||
if (isGeneratorFn(val)) { | ||
return 'generatorfunction' | ||
} else if (isAsyncFn(val)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for else if
here since the above condition already returns if true
. Same with the next condition.
Honestly, after thinking about this more I really don't think this is a good idea. Offhand, I can think of code that would break if we implement this. Everyone would need to start adding multiple conditions to their code. Instead, I suggest we expose a method, like |
Agree. |
Add async function detection. #22