This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathspec.html
48 lines (43 loc) · 1.9 KB
/
spec.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<pre class=metadata>
title: ES Promise.withResolvers (2023)
status: proposal
stage: 2
location: https://github.com/tc39/proposal-promise-with-resolvers
copyright: false
contributors: Peter Klecha
</pre>
<script src=ecmarkup.js defer></script>
<link rel=stylesheet href=ecmarkup.css>
<emu-intro id=introduction>
<h1>Introduction</h1>
<p>This is the formal specification for a proposed `Promise.withResolvers` method
in JavaScript. It modifies the original <a
href=https://tc39.github.io/ecma262/>ECMAScript specification</a> with
several new or revised clauses. See <a
href=https://github.com/tc39/proposal-promise-with-resolvers/blob/main/README.md>the proposal's
explainer</a> for the proposal's background, motivation, and usage examples.</p>
</emu-intro>
<emu-clause id="sec-control-abstraction-objects">
<h1>Control Abstraction Objects</h1>
<emu-clause id="sec-promise-objects">
<h1>Promise Objects</h1>
<emu-clause id="sec-properties-of-the-promise-constructor">
<h1>Properties of the Promise Constructor</h1>
<emu-clause id="sec-promise.withResolvers">
<h1>Promise.withResolvers ( )</h1>
<p>
This function returns an object with three properties: a new promise plus the `resolve` and `reject` functions associated with that promise.
</p>
<emu-alg>
1. Let _C_ be the *this* value.
1. Let _promiseCapability_ be ? NewPromiseCapability(_C_).
1. Let _obj_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_obj_, "promise", _promiseCapability_.[[Promise]]).
1. Perform ! CreateDataPropertyOrThrow(_obj_, "resolve", _promiseCapability_.[[Resolve]]).
1. Perform ! CreateDataPropertyOrThrow(_obj_, "reject", _promiseCapability_.[[Reject]]).
1. Return _obj_.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>