Skip to content

Commit

Permalink
Editorial: introduce CanonicalizeKeyedCollectionKey (#3337)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored and ljharb committed May 30, 2024
1 parent 6e70429 commit 30257dd
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -6811,7 +6811,7 @@ <h1>
1. IfAbruptCloseIterator(_key_, _iteratorRecord_).
1. Else,
1. Assert: _keyCoercion_ is ~zero~.
1. If _key_ is *-0*<sub>𝔽</sub>, set _key_ to *+0*<sub>𝔽</sub>.
1. Set _key_ to CanonicalizeKeyedCollectionKey(_key_).
1. Perform AddValueToKeyedGroup(_groups_, _key_, _value_).
1. Set _k_ to _k_ + 1.
</emu-alg>
Expand Down Expand Up @@ -41809,8 +41809,9 @@ <h1>Map.prototype.delete ( _key_ )</h1>
<emu-alg>
1. Let _M_ be the *this* value.
1. Perform ? RequireInternalSlot(_M_, [[MapData]]).
1. Set _key_ to CanonicalizeKeyedCollectionKey(_key_).
1. For each Record { [[Key]], [[Value]] } _p_ of _M_.[[MapData]], do
1. If _p_.[[Key]] is not ~empty~ and SameValueZero(_p_.[[Key]], _key_) is *true*, then
1. If _p_.[[Key]] is not ~empty~ and _p_.[[Key]] is _key_, then
1. Set _p_.[[Key]] to ~empty~.
1. Set _p_.[[Value]] to ~empty~.
1. Return *true*.
Expand Down Expand Up @@ -41863,8 +41864,9 @@ <h1>Map.prototype.get ( _key_ )</h1>
<emu-alg>
1. Let _M_ be the *this* value.
1. Perform ? RequireInternalSlot(_M_, [[MapData]]).
1. Set _key_ to CanonicalizeKeyedCollectionKey(_key_).
1. For each Record { [[Key]], [[Value]] } _p_ of _M_.[[MapData]], do
1. If _p_.[[Key]] is not ~empty~ and SameValueZero(_p_.[[Key]], _key_) is *true*, return _p_.[[Value]].
1. If _p_.[[Key]] is not ~empty~ and _p_.[[Key]] is _key_, return _p_.[[Value]].
1. Return *undefined*.
</emu-alg>
</emu-clause>
Expand All @@ -41875,8 +41877,9 @@ <h1>Map.prototype.has ( _key_ )</h1>
<emu-alg>
1. Let _M_ be the *this* value.
1. Perform ? RequireInternalSlot(_M_, [[MapData]]).
1. Set _key_ to CanonicalizeKeyedCollectionKey(_key_).
1. For each Record { [[Key]], [[Value]] } _p_ of _M_.[[MapData]], do
1. If _p_.[[Key]] is not ~empty~ and SameValueZero(_p_.[[Key]], _key_) is *true*, return *true*.
1. If _p_.[[Key]] is not ~empty~ and _p_.[[Key]] is _key_, return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>
Expand All @@ -41896,11 +41899,11 @@ <h1>Map.prototype.set ( _key_, _value_ )</h1>
<emu-alg>
1. Let _M_ be the *this* value.
1. Perform ? RequireInternalSlot(_M_, [[MapData]]).
1. Set _key_ to CanonicalizeKeyedCollectionKey(_key_).
1. For each Record { [[Key]], [[Value]] } _p_ of _M_.[[MapData]], do
1. If _p_.[[Key]] is not ~empty~ and SameValueZero(_p_.[[Key]], _key_) is *true*, then
1. If _p_.[[Key]] is not ~empty~ and _p_.[[Key]] is _key_, then
1. Set _p_.[[Value]] to _value_.
1. Return _M_.
1. If _key_ is *-0*<sub>𝔽</sub>, set _key_ to *+0*<sub>𝔽</sub>.
1. Let _p_ be the Record { [[Key]]: _key_, [[Value]]: _value_ }.
1. Append _p_ to _M_.[[MapData]].
1. Return _M_.
Expand Down Expand Up @@ -42091,10 +42094,10 @@ <h1>Set.prototype.add ( _value_ )</h1>
<emu-alg>
1. Let _S_ be the *this* value.
1. Perform ? RequireInternalSlot(_S_, [[SetData]]).
1. Set _value_ to CanonicalizeKeyedCollectionKey(_value_).
1. For each element _e_ of _S_.[[SetData]], do
1. If _e_ is not ~empty~ and SameValueZero(_e_, _value_) is *true*, then
1. If _e_ is not ~empty~ and _e_ is _value_, then
1. Return _S_.
1. If _value_ is *-0*<sub>𝔽</sub>, set _value_ to *+0*<sub>𝔽</sub>.
1. Append _value_ to _S_.[[SetData]].
1. Return _S_.
</emu-alg>
Expand Down Expand Up @@ -42126,8 +42129,9 @@ <h1>Set.prototype.delete ( _value_ )</h1>
<emu-alg>
1. Let _S_ be the *this* value.
1. Perform ? RequireInternalSlot(_S_, [[SetData]]).
1. Set _value_ to CanonicalizeKeyedCollectionKey(_value_).
1. For each element _e_ of _S_.[[SetData]], do
1. If _e_ is not ~empty~ and SameValueZero(_e_, _value_) is *true*, then
1. If _e_ is not ~empty~ and _e_ is _value_, then
1. Replace the element of _S_.[[SetData]] whose value is _e_ with an element whose value is ~empty~.
1. Return *true*.
1. Return *false*.
Expand Down Expand Up @@ -42184,8 +42188,9 @@ <h1>Set.prototype.has ( _value_ )</h1>
<emu-alg>
1. Let _S_ be the *this* value.
1. Perform ? RequireInternalSlot(_S_, [[SetData]]).
1. Set _value_ to CanonicalizeKeyedCollectionKey(_value_).
1. For each element _e_ of _S_.[[SetData]], do
1. If _e_ is not ~empty~ and SameValueZero(_e_, _value_) is *true*, return *true*.
1. If _e_ is not ~empty~ and _e_ is _value_, return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -42574,6 +42579,24 @@ <h1>Properties of WeakSet Instances</h1>
<p>WeakSet instances are ordinary objects that inherit properties from the WeakSet prototype. WeakSet instances also have a [[WeakSetData]] internal slot.</p>
</emu-clause>
</emu-clause>

<emu-clause id="sec-abstract-operations-for-keyed-collections">
<h1>Abstract Operations for Keyed Collections</h1>

<emu-clause id="sec-canonicalizekeyedcollectionkey" type="abstract operation">
<h1>
CanonicalizeKeyedCollectionKey (
_key_: an ECMAScript language value,
): an ECMAScript language value
</h1>
<dl class="header">
</dl>
<emu-alg>
1. If _key_ is *-0*<sub>𝔽</sub>, return *+0*<sub>𝔽</sub>.
1. Return _key_.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>

<emu-clause id="sec-structured-data">
Expand Down

0 comments on commit 30257dd

Please sign in to comment.