Closed moeen closed 5 years ago
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?
also, we were thinking about exposing options object as second argument,
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. Think about this:
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!
Just because we can, doesn't mean we should -- Ian Malcolm, Jurassic Park
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 isAsync
or something, so that we can achieve the same end result without changing current behavior.
Agree.
Add async function detection. #22