From ffb529a2d7508c33fe835fdce3fd6afe415835ff Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Sat, 30 Sep 2023 09:58:49 +0800 Subject: [PATCH] =?UTF-8?q?[Experimental]=20=E7=BB=99Map=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?polyfill=E4=B8=80=E4=BA=9B=E6=95=B0=E7=BB=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/game/game.js b/game/game.js index 4c3ce75fe..ebb180795 100644 --- a/game/game.js +++ b/game/game.js @@ -8173,6 +8173,59 @@ return this.childNodes[row].childNodes[col]; } }; + /*处理lib.nature的兼容性问题*/ + const mapHasFunc=function(item){ + return this.has(item) + }; + Object.defineProperty(Map.prototype, "contains",{ + configurable:true, + enumerable:false, + writable:true, + value:mapHasFunc + }); + Object.defineProperty(Map.prototype, "includes",{ + configurable:true, + enumerable:false, + writable:true, + value:mapHasFunc + }); + const mapAddFunc=function(item){ + this.set(item,0); + return this; + } + Object.defineProperty(Map.prototype, "add", { + configurable:true, + enumerable:false, + writable:true, + value:mapAddFunc + }); + Object.defineProperty(Map.prototype, "push", { + configurable:true, + enumerable:false, + writable:true, + value:mapAddFunc + }); + Object.defineProperty(Map.prototype, "addArray", { + configurable:true, + enumerable:false, + writable:true, + value:function(arr){ + for(var i=0;i