From c92d7f53098772e0c4d53dad0ca37e6bc7caf15e Mon Sep 17 00:00:00 2001 From: jacksplwxy <895685537@qq.com> Date: Thu, 12 May 2022 10:41:14 +0800 Subject: [PATCH] error when parse a big EngineData Maximum call stack size exceeded when parsing big engine data --- lib/parseEngineData.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/parseEngineData.js b/lib/parseEngineData.js index eb4df72..53e6ee2 100644 --- a/lib/parseEngineData.js +++ b/lib/parseEngineData.js @@ -26,7 +26,15 @@ var paresr = function(engineData){ function codeToString(engineData){ - return String.fromCharCode.apply(null, engineData); +// return String.fromCharCode.apply(null, engineData); + var res = ''; + var chunk = 8 * 1024; + var i; + for (i = 0; i < engineData.length / chunk; i++) { + res += String.fromCharCode.apply(null, engineData.slice(i * chunk, (i + 1) * chunk)); + } + res += String.fromCharCode.apply(null, engineData.slice(i * chunk)); + return res; } function textSegment(text){ @@ -67,7 +75,7 @@ function hashStart(text){ return { match: Match(reg, text), parse: function(){ - stackPush({}); + stackPush([]); } } } @@ -201,4 +209,4 @@ function pushKeyValue(key,value){ currentNode[key] = value; } -module.exports = paresr; \ No newline at end of file +module.exports = paresr;