cujojs/when — pull request #149 by Schoonology (2013-06-05 16:54:22+00:00)
Title: Added a method to attach "Node-style" callbacks as handlers.

**TL;DR:** This makes integrating with callback _users_ easier.

I tried to follow the structure as it was apparent, but please ask for updates if I've missed the mark. This met a need of mine, and I assume others may have similar needs.

**My use case:** I'm building a module for an application that uses promises, but the module is generic enough that I wanted it to accept callbacks, either. Therefore, the API looks thusly:

```javascript
function clear(callback) {
var self = this
, deferred = when.defer()

self.collection.drop(function (err) {
if (err) {
deferred.reject(err)
} else {
deferred.resolve(null)
}
})

deferred.promise.both(callback || noop)

return deferred.promise
}
```

This way, the callback is treated as both a callback and an errback, each a sibling of any downstream `then` handlers.