-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Clarify implementation reasoning #16
Comments
Regular expressions in older browsers have a Some native host objects return typeof function, but are not actually functions. Separately, classes are not callable - so although there's no way to accurately detect this (sadly), In other words, when |
Sure, but they're callable :) you can do
They're also callable, and work with all native functions (e.g. To my understanding callable is any object which has internal
They crash when not invoked with Anyway thanks for explanation, it's clearer for me, on why you decided on such route. |
True, you are correct that those regexes are callable :-) this module started as "is-function" and ended up a bit more generic.
|
Not true, if it wouldn't have that slot, any try to do After looking more thoroughly into ES2015 spec, I must say that this package is very confusing, especially that it doesn't reflect native ECMAScript isCallable behavior. |
The only valid argument I see here, is that it might be helpful to reject class constructors (for scenarios when we indeed expect plain functions). Still, first it will have to be confirmed whether there's a solid method to detect such constructors without false positives, I'm not sure if that's possible (?) I would also definitely rename this package to something as e.g. |
Thanks for the suggestion - I'm going to keep the name as-is. |
@ljharb I would suggest putting this explanation at the top of the readme, as I'm sure many are confused on what is the point of this. I at least looked at closed issues :) |
I just approached this package, and was a bit puzzled over it's complexity. To my understanding check for "is callable" in ES5+ world is as simple as
typeof value === 'function'
.What do I miss? Are there any new ES2015+ introductions that do not fall into that rule (class, async function, arrow function return
'function'
as expected)'function'
fortypeof
check'function'
fortypeof
check?I'll be grateful for clarification.
The text was updated successfully, but these errors were encountered: