@@ -168,11 +168,11 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
168168 - [ ` Math.sumPrecise ` ] ( #mathsumprecise )
169169 - [ Stage 3 proposals] ( #stage-3-proposals )
170170 - [ ` Iterator ` sequencing] ( #iterator-sequencing )
171+ - [ ` Map ` upsert] ( #map-upsert )
171172 - [ ` JSON.parse ` source text access] ( #jsonparse-source-text-access )
172173 - [ ` Symbol.metadata ` for decorators metadata proposal] ( #symbolmetadata-for-decorators-metadata-proposal )
173174 - [ Stage 2.7 proposals] ( #stage-27-proposals )
174175 - [ Joint iteration] ( #joint-iteration )
175- - [ ` Map ` upsert] ( #map-upsert )
176176 - [ Stage 2 proposals] ( #stage-2-proposals )
177177 - [ ` AsyncIterator ` helpers] ( #asynciterator-helpers )
178178 - [ ` Iterator.range ` ] ( #iteratorrange )
@@ -2712,6 +2712,42 @@ Iterator.concat([0, 1].values(), [2, 3], function * () {
27122712}()).toArray (); // => [0, 1, 2, 3, 4, 5]
27132713```
27142714
2715+ ##### [ ` Map ` upsert] ( https://github.com/thumbsupep/proposal-upsert ) [ ⬆] ( #index )
2716+ Modules [ ` esnext.map.get-or-insert ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.map.get-or-insert.js ) , [ ` esnext.map.get-or-insert-computed ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.map.get-or-insert-computed.js ) , [ ` esnext.weak-map.get-or-insert ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.weak-map.get-or-insert.js ) and [ ` esnext.weak-map.get-or-insert-computed ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.weak-map.get-or-insert-computed.js )
2717+ ``` ts
2718+ class Map {
2719+ getOrInsert(key : any , value : any ): any ;
2720+ getOrInsertComputed(key : any , (key : any ) => value : any): any ;
2721+ }
2722+
2723+ class WeakMap {
2724+ getOrInsert(key : any , value : any ): any ;
2725+ getOrInsertComputed(key : any , (key : any ) => value : any): any ;
2726+ }
2727+ ```
2728+ [ * CommonJS entry points:* ] ( #commonjs-api )
2729+ ```
2730+ core-js/proposals/map-upsert-v4
2731+ core-js(-pure)/actual|full/map/get-or-insert
2732+ core-js(-pure)/actual|full/map/get-or-insert-computed
2733+ core-js(-pure)/actual|full/weak-map/get-or-insert
2734+ core-js(-pure)/actual|full/weak-map/get-or-insert-computed
2735+ ```
2736+ [ * Examples* ] ( https://tinyurl.com/2a54u5ux ) :
2737+ ``` js
2738+ const map = new Map ([[' a' , 1 ]]);
2739+
2740+ map .getOrInsert (' a' , 2 ); // => 1
2741+
2742+ map .getOrInsert (' b' , 3 ); // => 3
2743+
2744+ map .getOrInsertComputed (' a' , key => key); // => 1
2745+
2746+ map .getOrInsertComputed (' c' , key => key); // => 'c'
2747+
2748+ console .log (map); // => Map { 'a': 1, 'b': 3, 'c': 'c' }
2749+ ```
2750+
27152751##### [ ` JSON.parse ` source text access] ( https://github.com/tc39/proposal-json-parse-with-source ) [ ⬆] ( #index )
27162752Modules [ ` esnext.json.is-raw-json ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.json.is-raw-json.js ) , [ ` esnext.json.parse ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.json.parse.js ) , [ ` esnext.json.raw-json ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.json.raw-json.js ) .
27172753``` ts
@@ -2827,42 +2863,6 @@ Iterator.zipKeyed({
28272863 */
28282864```
28292865
2830- ##### [ ` Map ` upsert] ( https://github.com/thumbsupep/proposal-upsert ) [ ⬆] ( #index )
2831- Modules [ ` esnext.map.get-or-insert ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.map.get-or-insert.js ) , [ ` esnext.map.get-or-insert-computed ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.map.get-or-insert-computed.js ) , [ ` esnext.weak-map.get-or-insert ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.weak-map.get-or-insert.js ) and [ ` esnext.weak-map.get-or-insert-computed ` ] ( https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.weak-map.get-or-insert-computed.js )
2832- ``` ts
2833- class Map {
2834- getOrInsert(key : any , value : any ): any ;
2835- getOrInsertComputed(key : any , (key : any ) => value : any): any ;
2836- }
2837-
2838- class WeakMap {
2839- getOrInsert(key : any , value : any ): any ;
2840- getOrInsertComputed(key : any , (key : any ) => value : any): any ;
2841- }
2842- ```
2843- [ * CommonJS entry points:* ] ( #commonjs-api )
2844- ```
2845- core-js/proposals/map-upsert-v4
2846- core-js(-pure)/full/map/get-or-insert
2847- core-js(-pure)/full/map/get-or-insert-computed
2848- core-js(-pure)/full/weak-map/get-or-insert
2849- core-js(-pure)/full/weak-map/get-or-insert-computed
2850- ```
2851- [ * Examples* ] ( https://tinyurl.com/2a54u5ux ) :
2852- ``` js
2853- const map = new Map ([[' a' , 1 ]]);
2854-
2855- map .getOrInsert (' a' , 2 ); // => 1
2856-
2857- map .getOrInsert (' b' , 3 ); // => 3
2858-
2859- map .getOrInsertComputed (' a' , key => key); // => 1
2860-
2861- map .getOrInsertComputed (' c' , key => key); // => 'c'
2862-
2863- console .log (map); // => Map { 'a': 1, 'b': 3, 'c': 'c' }
2864- ```
2865-
28662866#### Stage 2 proposals[ ⬆] ( #index )
28672867[ * CommonJS entry points:* ] ( #commonjs-api )
28682868```
0 commit comments