-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use is-callable
for a reliable function test across older engines as well
#9
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR. I did fix the instanceof slipup. If I'm not mistaken, bluebird, when and q all use that exact same test to test for thenables. If its good enough for them, its good enough (and consistent) for blue-tape. |
As the language gets more Realm support (which already works via the vm module and iframes) this will become more of a problem. They'll all have to fix it eventually ¯_(ツ)_/¯ |
Are you sure this applies to the current code, which now relies on typeof rather than instanceof? With the typeof change the only remaining examples are on the fringe of JS edge cases afaik - or am I missing something? |
Ah yes, sorry, you're right. If you're using In the future, the spec requires that class constructors (which aren't callable) be rejected, and if possible, |
👍 the future is now: https://nodejs.org/en/docs/es6/ |
It looks to me like native promises don't check for class constructors yet, and do infact try to invoke them (tested with node v5.1.0) var o = {then: class { constructor() { } } }
Promise.resolve(o).catch(e => console.log(e)) Output
Will keep this PR open for when things change though. |
@spion it's impossible to check for class constructors in a reliable cross-engine way. How would you check for Trying to invoke it synchronously is in fact the correct native behavior, per spec, as I understand it. However, it should reject the promise, and I don't believe node's v8 has caught up to that fix just yet. |
Hmm. I thought thats what you meant by
The promise was rejected though (with the error thrown by the class constructor being called without |
Originally that is what I intended, but in the meantime, sadly, Firefox shipped "class" without the ability to determine if a function is from a "class" or not. The spec does require that "class"es toString to the original class syntax, but I haven't bothered to write that code yet since some versions of Firefox will never have the ability to determine it. |
Fixes #7.