-
Notifications
You must be signed in to change notification settings - Fork 21
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
How to create Bluebird promises from async functions #29
Comments
And basically, I don't care how promises internally work in nodent. I'd just like the return value to come from bluebird like so |
Note: when using |
Nodent doesn't care what type of promise you define (assuming you're using -promise mode, which is the default). If you set However, be aware that the standard implementation (eg in V8 5.4) does not work this way, and always used the native Promise implementation, so code written in the style you're proposing won't run on native async/await implementations without transpilation. |
The problem is that babel re-writes |
I'll take a quick look at how babel mangles Promises, but fast-async/nodent don't use any particular Promise implementation in "use nodent-promises" mode - it just references the global symbol "Promise" in the same way that your own code would. It would seem you need an option to stop babel over-writing "Promise" if that is what's happening. fast-async only falls back to Zousan if you're using "-es7" mode, not the other modes. |
The solution is to put fast-async before any modules that mangle Promises. I changed the .bablerc (see below) and it seems to work. I don't know what the other plugins/presets are doing, but at least one of them is over-writing "Promise".
|
Thank you, this indeed works. It might be a good tip to put this information into README. |
Given the below code, how to configure fast-async/nodent to return bluebird promises?
The text was updated successfully, but these errors were encountered: