This sweet.js macro will help you turn any standard callback-based function into a promise, using whichever promise library you want.
Here's an example using when and the standard
If you are totally new to macros, I recommend reading this excellent article:
Writing Your First Sweet.js Macro by James Long
resolver macro will match the following pattern:
And expand it to:
This allows you to wrap that resolver function in any promise library you want. It will take
any arguments in
ARGS... and pass them to
FUNCTION, and then add on the callback handling
function for you.