Modify Promise.all() to accept an Object as a parameter

bread at bread at
Fri Apr 10 08:44:52 UTC 2015

This proposal came out of

The proposal is to augment Promise.all() to accept an Object as a parameter, which return a corresponding object (or Promise for such an object) such the each field of the Object, if it were a Promise is resolved, and if not it is otherwise returned unmodified.

The exact semantics are such that each data member of the Object is treated as if it were an Array entry as passed to Promise.all() currently.

The purpose of the modification is to allow labelling of each Promise at a point close to the value of the Promise to quickly and easily show the developers intent.

Implementation is relatively easy, and Promise implementation agnostic (although the simplicity of the API makes implementation-specific optimization possible).

No view has been taken on how non-Promise/value members of the Object should be treated (ignored? throw Error?), or whether nested Objects should be resolved (potentially confusing, but useful for combining results from other calls that return Objects containing Promises for final resolution).

For example (taken from

var r = await Promise.all({
}) ;

redirect(r.URL+"?"+r.input); opposed to:
var r = await Promise.all([
]) ;

This has the advantage of keeping the operation and name in close proximity, making the intent easier to spot, is fully ES5 friendly with respect to the await expression and response, allows for nested parallel Promises, and in any case is a runtime implementation and so the programmer can alias the function.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list