medikoo (2017-04-14T07:59:11.000Z)
While Promise methods and functions are friendly for it's extensions (or even
not direct extensions but just thenables), the async function will always
normalize it's result to instance of Promise, even it's ExtendedPromise,
e.g.:class ExtendedPromise extends Promise {};var extendedPromise = new
ExtendedPromise(function (resolve) { resolve();
});extendedPromise.then().constructor === ExtendedPromise // truevar asyncFn
= async function () { return extendedPromise; };asyncFn().constructor ===
ExtendedPromise // falseasyncFn().constructor === Promise // trueThat makes
it cumbersome if we work with promise extensions. What was the reasoning
behind such design?If not thenables in general, the promise extensions I
believe should be passed through (or copied via its constructor.resolve).



--
View this message in context: http://mozilla.6506.n7.nabble.com/Async-functions-not-friendly-to-promise-extensions-tp364921.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170414/8cdfca57/attachment.html>
medikoo+github.com at medikoo.com (2017-04-14T08:00:45.041Z)
While Promise methods and functions are friendly for it's extensions (or even not direct extensions but just thenables), the async function will always normalize it's result to instance of Promise, even it's ExtendedPromise, e.g.:

class ExtendedPromise extends Promise {};

var extendedPromise = new ExtendedPromise(function (resolve) { resolve(); });

extendedPromise.then().constructor === ExtendedPromise // true

var asyncFn = async function () { return extendedPromise; };

asyncFn().constructor === ExtendedPromise // false

asyncFn().constructor === Promise // true

That makes it cumbersome if we work with promise extensions. What was the reasoning behind such design?If not thenables in general, the promise extensions I believe should be passed through (or copied via its constructor.resolve).

--
View this message in context: http://mozilla.6506.n7.nabble.com/Async-functions-not-friendly-to-promise-extensions-tp364921.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.
medikoo+github.com at medikoo.com (2017-04-14T08:00:27.629Z)
While Promise methods and functions are friendly for it's extensions (or even not direct extensions but just thenables), the async function will always normalize it's result to instance of Promise, even it's ExtendedPromise, e.g.:

class ExtendedPromise extends Promise {};

var extendedPromise = new ExtendedPromise(function (resolve) { resolve(); });
extendedPromise.then().constructor === ExtendedPromise // true

var asyncFn = async function () { return extendedPromise; };
asyncFn().constructor === ExtendedPromise // false
asyncFn().constructor === Promise // true

That makes it cumbersome if we work with promise extensions. What was the reasoning behind such design?If not thenables in general, the promise extensions I believe should be passed through (or copied via its constructor.resolve).

--
View this message in context: http://mozilla.6506.n7.nabble.com/Async-functions-not-friendly-to-promise-extensions-tp364921.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.