medikoo (2017-04-14T07:59:11.000Z)
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.