diff --git a/index.html b/index.html index 2e009b8..e84cedf 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,7 @@

Stage 2 Draft / November 25, 2023

Set methods

+

Stage 2 Draft / December 3, 2023

Set methods

1 Set.prototype.union ( other )

@@ -26,7 +26,7 @@

2 Set.prototype.intersection ( other

3 Set.prototype.difference ( other )

This method performs the following steps when called:

-
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[SetData]]).
  3. Let otherRec be ? GetSetRecord(other).
  4. Let resultSetData be a copy of O.[[SetData]].
  5. Let thisSize be the number of elements in O.[[SetData]].
  6. If thisSizeotherRec.[[Size]], then
    1. Let index be 0.
    2. Repeat, while index < thisSize,
      1. Let e be resultSetData[index].
      2. Set index to index + 1.
      3. If e is not empty, then
        1. Let inOther be ToBoolean(? Call(otherRec.[[Has]], otherRec.[[Set]], « e »)).
        2. If inOther is true, then
          1. Set resultSetData[index] to empty.
  7. Else,
    1. Let keysIter be ? GetIteratorFromMethod(otherRec.[[Set]], otherRec.[[Keys]]).
    2. Let next be true.
    3. Repeat, while next is not false,
      1. Set next to ? IteratorStep(keysIter).
      2. If next is not false, then
        1. Let nextValue be ? IteratorValue(next).
        2. If nextValue is -0𝔽, set nextValue to +0𝔽.
        3. If SetDataHas(resultSetData, nextValue) is true, then
          1. Remove nextValue from resultSetData.
  8. Let result be OrdinaryObjectCreate(%Set.prototype%, « [[SetData]] »).
  9. Set result.[[SetData]] to resultSetData.
  10. Return result.
+
  1. Let O be the this value.
  2. Perform ? RequireInternalSlot(O, [[SetData]]).
  3. Let otherRec be ? GetSetRecord(other).
  4. Let resultSetData be a copy of O.[[SetData]].
  5. Let thisSize be the number of elements in O.[[SetData]].
  6. If thisSizeotherRec.[[Size]], then
    1. Let index be 0.
    2. Repeat, while index < thisSize,
      1. Let e be resultSetData[index].
      2. If e is not empty, then
        1. Let inOther be ToBoolean(? Call(otherRec.[[Has]], otherRec.[[Set]], « e »)).
        2. If inOther is true, then
          1. Set resultSetData[index] to empty.
      3. Set index to index + 1.
  7. Else,
    1. Let keysIter be ? GetIteratorFromMethod(otherRec.[[Set]], otherRec.[[Keys]]).
    2. Let next be true.
    3. Repeat, while next is not false,
      1. Set next to ? IteratorStep(keysIter).
      2. If next is not false, then
        1. Let nextValue be ? IteratorValue(next).
        2. If nextValue is -0𝔽, set nextValue to +0𝔽.
        3. If SetDataHas(resultSetData, nextValue) is true, then
          1. Remove nextValue from resultSetData.
  8. Let result be OrdinaryObjectCreate(%Set.prototype%, « [[SetData]] »).
  9. Set result.[[SetData]] to resultSetData.
  10. Return result.