mbostock/queue — pull request #20 by mbostock (2014-03-03 17:53:15+00:00)
Title: Promises for queue.

I’m not sure this is a good idea, but I wanted to try it. For example, it lets you take something like this:

```js
queue(1)
.defer(getSettings)
.defer(gitInit)
.defer(gitRemoteOriginDoesNotExist)
.defer(gitListUntrackedFiles)
.await(function(error, settings, _, _, files) {
if (error) throw error;
queue(1)
.defer(confirmFiles, files)
.defer(gitAdd, files)
.defer(gitCommit)
.defer(createGist, settings.token)
.await(function(error, _, _, _, id) {
if (error) throw error;
queue(1)
.defer(gitRemoteAdd, id)
.defer(gitPush)
.defer(openBrowser, id)
.await(unless);
});
});
```

And transform it into this:

```js
queue.then(function() {
return queue(1)
.defer(getSettings)
.defer(gitInit)
.defer(gitRemoteOriginDoesNotExist)
.defer(gitListUntrackedFiles);
}, function(error) {
throw error;
}).then(function(settings, _, _, files) {
return queue(1)
.defer(confirmFiles, files)
.defer(gitAdd, files)
.defer(gitCommit)
.defer(createGist, settings.token);
}).then(function(_, _, _, id) {
return queue(1)
.defer(gitRemoteAdd, id)
.defer(gitPush)
.defer(openBrowser, id);
});
```