-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Promise.coroutine should respect the arity of the generator function being wrapped? #927
Comments
This is not something that can be fixed by bluebird at all. It's cucumber-js which is making a pretty silly decision to rely on |
Fair enough and I agree more or less. cucumberjs aside, Do you mind explaining why is this something that cannot or should not be implemented? I don't see this as bug, more of a missing feature. (P.S: Currently looking into how to programmatically create anonymous wrapper functions with matching arity) |
The only way to do it is with |
Fair enough, that does make it unreasonable. |
@petkaantonov in node, Firefox and Chrome (I couldn't immediately check other environments) it is actually possible to do this using
|
@phpnode oh that's cool |
great news! this is "a way" to achieve what I was looking for:
@phpnode not entirely clear on how your example works, but if theres anything I can do, let me know. |
@renegare like I said before, |
@renegare it should be straightforward to function co(gen) {
var len = gen.length;
var coFn = Promise.coroutine(gen);
Object.defineProperty(coFn, 'length', {value: len})
return coFn;
} |
hence why the above is not a PR. just an example of the desired functionality ;) |
@spion I see! yeah I was confused about how to apply it. Apologies guys if the eval example implied the right way to do it. Nice one 👍 |
Shall I have a stab at a PR? |
Sure if you are up for it, but make sure you use the es5.js's defineProperty as it works in IE as well. |
Hey I believe its done. Feedback comments are welcome. Idea, would it be cool to set the |
Fixed in 3.1.2 |
Hi guys,
My use case is in the context of a cucumber-js step definition:
Currently the above step when executed will return the following error from cucumber-js:
I appreciate this could be something cucumber-js should avoid throwing an error on or I solve it locally in my project, but I feel it would be a useful change within bluebird for all.
Thoughts?
The text was updated successfully, but these errors were encountered: