briancavalier/when.js — Issue #16: Array-based methods (e.g. when.all/map/reduce) should also accept a promise for an array
Author: briancavalier
Created: 2012-01-14 19:37:33+00:00
State: open

For example:

```javascript
var d = when.defer();

when.all(d.promise, function(resultsArray) { ... });

// d may resolve to a mixed array of values and promises
var d2 = when.defer();
d.resolve([1, 2, d2]);

d2.resolve(3);
```

One practical example of where this could be very helpful is Dojo's data stores, which can return a promise for an array:

```javascript
when.map(datastore.query({ ... }), mapperFunction).then(doSomethingWithMappedResults);
```

Implementing this is simple, but will probably make the solution to #15 insufficient, and we'll have to check parameters at the API boundary (e.g. directly in when.all), instead of relying on the checks in `.then()`.