From 416332613e9e226cb368801be445b599c9fc19ac Mon Sep 17 00:00:00 2001 From: dminor Date: Tue, 3 Dec 2024 17:49:02 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc39/pro?= =?UTF-8?q?posal-upsert@4c1b90f54c17f3f62c28ae04552859297f608bb5=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index f840161..0fdf63a 100644 --- a/index.html +++ b/index.html @@ -46,7 +46,7 @@

Stage 2 Draft / November 29, 2024

Map.prototype.getOrInsert

+

Stage 2 Draft / December 3, 2024

Map.prototype.getOrInsert

Introduction

@@ -65,7 +65,7 @@

1 Map.prototype.getOrInsert ( key,

2 Map.prototype.getOrInsertComputed ( key, callbackfn )

When the getOrInsertComputed method is called the following steps are taken:

-
  1. Let M be the this value.
  2. Perform ? RequireInternalSlot(M, [[MapData]]).
  3. If IsCallable(callbackfn) is false, throw a TypeError exception.
  4. Set key to CanonicalizeKeyedCollectionKey(key).
  5. For each Record { [[Key]], [[Value]] } p of M.[[MapData]], do
    1. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
  6. Let value be ? Call(callbackfn, undefined, « key »).
  7. Let p be the Record { [[Key]]: key, [[Value]]: value }.
  8. Append p to M.[[MapData]].
  9. Return value.
+
  1. Let M be the this value.
  2. Perform ? RequireInternalSlot(M, [[MapData]]).
  3. If IsCallable(callbackfn) is false, throw a TypeError exception.
  4. Set key to CanonicalizeKeyedCollectionKey(key).
  5. For each Record { [[Key]], [[Value]] } p of M.[[MapData]], do
    1. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
  6. Let value be ? Call(callbackfn, undefined, « key »).
  7. For each Record { [[Key]], [[Value]] } p of M.[[MapData]], do
    1. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
      1. Set p.[[Value]] to value.
      2. Return value.
  8. Let p be the Record { [[Key]]: key, [[Value]]: value }.
  9. Append p to M.[[MapData]].
  10. Return value.
@@ -77,7 +77,7 @@

3 WeakMap.prototype.getOrInsert ( key

4 WeakMap.prototype.getOrInsertComputed ( key, callbackfn )

When the getOrInsertComputed method is called the following steps are taken:

-
  1. Let M be the this value.
  2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
  3. If IsCallable(callbackfn) is false, throw a TypeError exception.
  4. If CanBeHeldWeakly(key) is false, throw a TypeError exception.
  5. For each Record { [[Key]], [[Value]] } p of M.[[WeakMapData]], do
    1. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
  6. Let value be ? Call(callbackfn, undefined, « key »).
  7. Let p be the Record { [[Key]]: key, [[Value]]: value }.
  8. Append p to M.[[WeakMapData]].
  9. Return value.
+
  1. Let M be the this value.
  2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
  3. If IsCallable(callbackfn) is false, throw a TypeError exception.
  4. If CanBeHeldWeakly(key) is false, throw a TypeError exception.
  5. For each Record { [[Key]], [[Value]] } p of M.[[WeakMapData]], do
    1. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
  6. Let value be ? Call(callbackfn, undefined, « key »).
  7. For each Record { [[Key]], [[Value]] } p of M.[[WeakMapData]], do
    1. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
      1. Set p.[[Value]] to value.
      2. Return value.
  8. Let p be the Record { [[Key]]: key, [[Value]]: value }.
  9. Append p to M.[[WeakMapData]].
  10. Return value.

A Copyright & Software License