Async functions not friendly to promise extensions
medikoo
medikoo+mozilla.org at medikoo.com
Fri Apr 14 10:31:33 UTC 2017
> You seem to misunderstand what async functions do to be async, Your
function has the same product as the following:
> new Promise((acc, rej) => acc(extendedPromise))
Yes, I totally understand that, and it's clear to me that it's that way. In
my post I question that design, as it seems to me that way nicer would be if
it's as follows:
If (isThenable(result)) return result;
else return new Promise((resolve, reject) => resolve(result));
Or if above seems too liberal, then at least:
if (isPromise(result)) return new result.constructor((resolve, reject) =>
resolve(result));
else return new Promise((resolve, reject) => resolve(result));
> By no means do async functions use the returned values as their way of
> determining what type of promise
they are: that'd break when using multiple returns with different types.
> I hope this explains it a bit for you.
Sorry, but it didn't explain much. What to you mean by "that'd break when
using multiple returns with different types" ? Can you throw some simple
example?
--
View this message in context: http://mozilla.6506.n7.nabble.com/Async-functions-not-friendly-to-promise-extensions-tp364921p364924.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.
More information about the es-discuss
mailing list