kriskowal/q — Issue #27: feature request: deferred provides Node-style callback
Author: csosborn
Created: 2011-10-12 18:54:57+00:00
State: open

I often find myself wrapping Node-style API methods in promises, and doing something like the following:

var def = Q.defer();
doSomething(a, b, function(err, result) {
if (err) {
def.reject(err);
} else {
def.resolve(result);
}
});
return def.promise;

It would be great if I could do this instead:

var def = Q.defer();
doSomething(a, b, def.callback());
return def.promise;

Would that be possible?