Skip to content

Commit 6b0baee

Browse files
committed
Editorial: Merge keys and values into a single list of records
1 parent 75e4432 commit 6b0baee

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

spec.emu

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@ contributors: Alexander J. Vincent, Ashley Claymore, Chris de Almeida, Jordan Ha
1919
<h1>
2020
<ins>
2121
CreateKeyedPromiseCombinatorResultObject (
22-
_keys_: a List of property keys,
23-
_values_: a List of ECMAScript language values,
22+
_entries_: a List of Records with fields [[Key]] (a property key) and [[Value]] (an ECMAScript language value),
2423
): an Object
2524
</ins>
2625
</h1>
2726
<dl class="header">
2827
</dl>
2928
<emu-alg>
30-
1. Assert: The number of elements in _keys_ is the same as the number of elements in _values_.
3129
1. Let _obj_ be OrdinaryObjectCreate(*null*).
32-
1. For each integer _i_ such that 0 ≤ _i_ &lt; the number of elements in _keys_, in ascending order, do
33-
1. Perform ! CreateDataPropertyOrThrow(_obj_, _keys_[_i_], _values_[_i_]).
30+
1. For each Record { [[Key]], [[Value]] } _entry_ of _entries_, do
31+
1. Perform ! CreateDataPropertyOrThrow(_obj_, _entry_.[[Key]], _entry_.[[Value]]).
3432
1. Return _obj_.
3533
</emu-alg>
3634
</emu-clause>
@@ -80,34 +78,32 @@ contributors: Alexander J. Vincent, Ashley Claymore, Chris de Almeida, Jordan Ha
8078
</dl>
8179
<emu-alg>
8280
1. Let _allKeys_ be ? _promises_.[[OwnPropertyKeys]]().
83-
1. Let _keys_ be a new empty List.
84-
1. Let _values_ be a new empty List.
81+
1. Let _entries_ be a new empty List.
8582
1. Let _remainingElementsCount_ be the Record { [[Value]]: 1 }.
8683
1. Let _index_ be 0.
8784
1. For each element _key_ of _allKeys_, do
8885
1. Let _propertyDesc_ be ? _promises_.[[GetOwnProperty]](_key_).
8986
1. If _propertyDesc_ is not *undefined* and _propertyDesc_.[[Enumerable]] is *true*, then
9087
1. Let _propertyValue_ be ? Get(_promises_, _key_).
91-
1. Append _key_ to _keys_.
92-
1. Append *undefined* to _values_.
88+
1. Append the Record { [[Key]]: _key_, [[Value]]: *undefined* } to _entries_.
9389
1. Let _nextPromise_ be ? Call(_promiseResolve_, _ctor_, « _propertyValue_ »).
9490
1. Let _alreadyCalled_ be the Record { [[Value]]: *false* }.
95-
1. Let _fulfilledSteps_ be a new Abstract Closure with parameters (_value_) that captures _variant_, _keys_, _values_, _resultCapability_, and _remainingElementsCount_ and performs the following steps when called:
91+
1. Let _fulfilledSteps_ be a new Abstract Closure with parameters (_value_) that captures _variant_, _entries_, _resultCapability_, and _remainingElementsCount_ and performs the following steps when called:
9692
1. Let _activeFunc_ be the active function object.
9793
1. If _activeFunc_.[[AlreadyCalled]].[[Value]] is *true*, return *undefined*.
9894
1. Set _activeFunc_.[[AlreadyCalled]].[[Value]] to *true*.
9995
1. Let _thisIndex_ be _activeFunc_.[[Index]].
10096
1. If _variant_ is ~all~, then
101-
1. Set _values_[_thisIndex_] to _value_.
97+
1. Set _entries_[_thisIndex_].[[Value]] to _value_.
10298
1. Else,
10399
1. Assert: _variant_ is ~all-settled~.
104100
1. Let _obj_ be OrdinaryObjectCreate(%Object.prototype%).
105101
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"status"*, *"fulfilled"*).
106102
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"value"*, _value_).
107-
1. Set _values_[_thisIndex_] to _obj_.
103+
1. Set _entries_[_thisIndex_].[[Value]] to _obj_.
108104
1. Set _remainingElementsCount_.[[Value]] to _remainingElementsCount_.[[Value]] - 1.
109105
1. If _remainingElementsCount_.[[Value]] = 0, then
110-
1. Let _result_ be CreateKeyedPromiseCombinatorResultObject(_keys_, _values_).
106+
1. Let _result_ be CreateKeyedPromiseCombinatorResultObject(_entries_).
111107
1. Return ? Call(_resultCapability_.[[Resolve]], *undefined*, « _result_ »).
112108
1. Return *undefined*.
113109
1. Let _onFulfilled_ be CreateBuiltinFunction(_fulfilledSteps_, 1, *""*, « [[AlreadyCalled]], [[Index]] »).
@@ -117,18 +113,18 @@ contributors: Alexander J. Vincent, Ashley Claymore, Chris de Almeida, Jordan Ha
117113
1. Let _onRejected_ be _resultCapability_.[[Reject]].
118114
1. Else,
119115
1. Assert: _variant_ is ~all-settled~.
120-
1. Let _rejectedSteps_ be a new Abstract Closure with parameters (_error_) that captures _keys_, _values_, _resultCapability_, and _remainingElementsCount_ and performs the following steps when called:
116+
1. Let _rejectedSteps_ be a new Abstract Closure with parameters (_error_) that captures _entries_, _resultCapability_, and _remainingElementsCount_ and performs the following steps when called:
121117
1. Let _activeFunc_ be the active function object.
122118
1. If _activeFunc_.[[AlreadyCalled]].[[Value]] is *true*, return *undefined*.
123119
1. Set _activeFunc_.[[AlreadyCalled]].[[Value]] to *true*.
124120
1. Let _thisIndex_ be _activeFunc_.[[Index]].
125121
1. Let _obj_ be OrdinaryObjectCreate(%Object.prototype%).
126122
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"status"*, *"rejected"*).
127123
1. Perform ! CreateDataPropertyOrThrow(_obj_, *"reason"*, _error_).
128-
1. Set _values_[_thisIndex_] to _obj_.
124+
1. Set _entries_[_thisIndex_].[[Value]] to _obj_.
129125
1. Set _remainingElementsCount_.[[Value]] to _remainingElementsCount_.[[Value]] - 1.
130126
1. If _remainingElementsCount_.[[Value]] = 0, then
131-
1. Let _result_ be CreateKeyedPromiseCombinatorResultObject(_keys_, _values_).
127+
1. Let _result_ be CreateKeyedPromiseCombinatorResultObject(_entries_).
132128
1. Return ? Call(_resultCapability_.[[Resolve]], *undefined*, « _result_ »).
133129
1. Return *undefined*.
134130
1. Let _onRejected_ be CreateBuiltinFunction(_rejectedSteps_, 1, *""*, « [[AlreadyCalled]], [[Index]] »).
@@ -139,8 +135,8 @@ contributors: Alexander J. Vincent, Ashley Claymore, Chris de Almeida, Jordan Ha
139135
1. Set _index_ to _index_ + 1.
140136
1. Set _remainingElementsCount_.[[Value]] to _remainingElementsCount_.[[Value]] - 1.
141137
1. If _remainingElementsCount_.[[Value]] = 0, then
142-
1. NOTE: This can happen even if _keys_ was non-empty if an ill-behaved thenable synchronously invoked the callback passed to its *"then"* method.
143-
1. Let _result_ be CreateKeyedPromiseCombinatorResultObject(_keys_, _values_).
138+
1. NOTE: This can happen even if _entries_ is non-empty if an ill-behaved thenable synchronously invoked the callback passed to its *"then"* method.
139+
1. Let _result_ be CreateKeyedPromiseCombinatorResultObject(_entries_).
144140
1. Perform ? Call(_resultCapability_.[[Resolve]], *undefined*, « _result_ »).
145141
1. Return _resultCapability_.[[Promise]].
146142
</emu-alg>

0 commit comments

Comments
 (0)