- From: Ms2ger <notifications@github.com>
- Date: Mon, 26 Aug 2019 02:26:28 -0700
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <heycam/webidl/pull/772/review/279464000@github.com>
Ms2ger commented on this pull request. > <div id="es-to-promise" algorithm="convert an ECMAScript value to promise"> An ECMAScript value |V| is [=converted to an IDL value|converted=] - to an IDL <a interface lt="Promise">Promise<var ignore>T</var></a> value as follows: + to an IDL <code>{{Promise}}<<var ignore>T</var>></code> value as follows: Bah. > 1. Let |reason| be the result of [=converted to an IDL value|converting=] |R| to an IDL value of type {{any}}. 1. If there are no steps that are required to be run if the promise was rejected, then return <emu-val>undefined</emu-val>. - 1. Otherwise, return the result of performing any steps that were required to be run if the promise was rejected, - with |reason| as the rejection reason. - 1. Return [=!=] [$PerformPromiseThen$](|promise|, |onFulfilled|, |onRejected|). + 1. Let |result| be the result of performing any steps that were required to be run if the + promise was rejected, given |reason|. + 1. Return |result|, [=converted to an ECMAScript value=]. + 1. Let |onRejected| be [=!=] [$CreateBuiltinFunction$](|onRejectedSteps|, « »): + 1. Let |constructor| be |promise|.\[[Promise]].\[[Realm]].\[[Intrinsics]].[[{{%Promise%}}]]. + 1. Let |newCapability| be ? [$NewPromiseCapability$](|constructor|). + 1. Return [=!=] [$PerformPromiseThen$](|promise|.\[[Promise]], |onFulfilled|, |onRejected|, |newCapability|). + + Note: If the provided steps return a value of type |T|, this algorithm returns a + <code>{{Promise}}<<var ignore>T</var>></code>. Yeah, definitely not T. Tried to clarify a bit. > + <pre highlight="webidl"> + interface I { + Promise<void> delay(unrestricted double ms); + }; + </pre> + +<div algorithm="delay"> + + The <code>delay(|ms|)</code> method steps are: + + 1. Let |realm| be <b>this</b>'s [=relevant Realm=]. + 1. If |ms| is NaN, let |ms| be +0; otherwise let |ms| be the maximum of |ms| and +0. + 1. Let |p| be [=Promise/a new promise=] in |realm|. + 1. Run the following steps [=in parallel=]: + 1. Wait |ms| milliseconds. + 1. [=Promise/Resolve=] |p| with the {{void}} value. Could be, yes. I'm not entirely sure how to phrase that, though. > 1. Let |R| be the first argument to |onRejected|. 1. Let |reason| be the result of [=converted to an IDL value|converting=] |R| to an IDL value of type {{any}}. 1. If there are no steps that are required to be run if the promise was rejected, then return <emu-val>undefined</emu-val>. 1. Otherwise, return the result of performing any steps that were required to be run if the promise was rejected, with |reason| as the rejection reason. - 1. Return [=!=] [$PerformPromiseThen$](|promise|, |onFulfilled|, |onRejected|). + 1. Let |onRejected| be [=!=] [$CreateBuiltinFunction$](|onRejectedSteps|, « »): + 1. Let |constructor| be |promise|.\[[Promise]].\[[Realm]].\[[Intrinsics]].[[{{%Promise%}}]]. + 1. Let |newCapability| be ? [$NewPromiseCapability$](|constructor|). + 1. Return [=!=] [$PerformPromiseThen$](|promise|.\[[Promise]], |onFulfilled|, |onRejected|, |newCapability|). Right, I meant to call that out explicitly, but it seems I forgot. I could add a note that it's not necessary to create the PromiseCapability -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/heycam/webidl/pull/772#discussion_r317502613
Received on Monday, 26 August 2019 09:26:51 UTC