Propose:
Add the array based methods of when to the Promise interface:
all, settle, map, filter, reduce, reduceRight, any, and some
Justification:
Often the input for these methods will the resolved value of a promise, for example the result of an api request. As these methods are not on the Promise interface, this requires the use of a then that bridges to these methods.
Adding these methods to the Promise interface would result in cleaner code, and avoid an unnecessary intermediate step.
I think that the majority of use cases would be using the map, filter, reduce/reduceRight but that the other methods would be worth including for completeness.
Behaviour when used on a promise that resolves to a single value rather than an array could either copy spreads behaviour and not pass any argument, or convert the value to an array of one.
Propose: Add the array based methods of when to the Promise interface: all, settle, map, filter, reduce, reduceRight, any, and some
Justification: Often the input for these methods will the resolved value of a promise, for example the result of an api request. As these methods are not on the Promise interface, this requires the use of a then that bridges to these methods.
Adding these methods to the Promise interface would result in cleaner code, and avoid an unnecessary intermediate step.
Examples: Map:
Filter:
Combined:
I think that the majority of use cases would be using the map, filter, reduce/reduceRight but that the other methods would be worth including for completeness.
Behaviour when used on a promise that resolves to a single value rather than an array could either copy spreads behaviour and not pass any argument, or convert the value to an array of one.