-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
ES.isCallable not spec compliant #48
Comments
It's unfortunate that I'd be happy to change |
Why not use your toString / class regex logic from is-callable to implement |
It's not reliable due to many browsers not toStringing |
This looks like an interesting approach: https://stackoverflow.com/a/46759625 |
Is Reflect in any engine that lacks Proxy? If it’s not polyfillable it’s not much of an approach :-/ |
The current Also, there’s a simpler const isConstructorMarker = {};
const badArrayLike = {
get length() {
throw isConstructorMarker;
}
};
const IsConstructor = value => {
try {
Reflect.construct(value, badArrayLike);
} catch (err) {
return err === isConstructorMarker;
}
}; This is because Although, it won’t work in environments that don’t support getters. |
It looks like
ES.isCallable
simply leverages theis-callable
package. However as noted in inspect-js/is-callable#16, that implementation is not equivalent to theIsCallable
from the spec.Class constructors do have a
[[Call]]
internal slot which makes them callable.The
[[Call]]
internal method throws TypeError if[[FunctionKind]] == "classConstructor"
, but that's simply the implementation of the internal method.The text was updated successfully, but these errors were encountered: