Introduction of promise.return() and promise.throw() similar to generator.return() and generator.throw() can be helpful
Assuming analogy in tuples ([``function*``](https:// developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ Statements/function*), [``yield``](https://developer. mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield), [``Generator.prototype.return()``](https://developer. mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_ Objects/Generator/return), [``Generator.prototype.throw()``]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/ Reference/Global_Objects/Generator/throw) ) and ([``async function``]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ Operators/async_function), [``await``](https://developer. mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await), ``?Promise.prototype.return()``, ``?Promise.prototype.throw()``), it would be good to have ``Promise.prototype.return()`` and ``Promise.prototype.throw()`` which in case of ``async``/``await`` function should just "inject" some [``return``](https://developer.mozilla.org/en-US/ docs/Web/JavaScript/Reference/Statements/return)/[``throw``] (https://developer.mozilla.org/en-US/docs/Web/JavaScript/ Reference/Statements/throw <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return)/%5Bthrow%5D(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw>) action in place of pending ``await`` statement. While for ``.then``-like promises it should just force promise to abnormal completion (with provided result) without calling callbacks provided in .``then``/.``catch`` methods (if they was not yet called before, at the time of "abruption" attempt).
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

