3 ms·
Wrapping every standard library method with my own promises sounds like just another flavour of hell, and it still doesn't address the fact that the standard li
by ihsw 10y ago
Wrapping every standard library method with my own promises sounds like just another flavour of hell, and it still doesn't address the fact that the standard library is callback hell.
- sotojuan 10y agoI agree with you but FWIW there are both big (Bluebird) and small (pinky-promise) packages to promisify stuff.
- always_good 10y agoCallback hell isn't the characteristic of having a callback-based API. It's the code you get when you try to compose it and conditionally fork it without any better abstractions. So promisifying a callback-based API does address it by either letting you use a yield/await abstraction or at the very least promise composition. Wrapping a callback-based API is such a mechanical process that you can wrap entire modules at a time, so I'm not sure what's hellish about that when it gives you promises, something you can actually work with.
- WorldMaker 10y agopromise-ring is one library that does the wrapping automatically from node-style callbacks to promises. I think Bluebird also has an auto-wrapper.