diff --git a/std/portable/index.js b/std/portable/index.js index 80aeae3834..9271173249 100644 --- a/std/portable/index.js +++ b/std/portable/index.js @@ -198,11 +198,39 @@ globalScope["changetype"] = function changetype(value) { }; String["fromCharCodes"] = function fromCharCodes(arr) { - return String.fromCharCode.apply(String, arr); + const CHUNKSIZE = 1 << 13; + const len = arr.length; + if (len <= CHUNKSIZE) { + return String.fromCharCode.apply(String, arr); + } + let index = 0; + let parts = ''; + while (index < len) { + parts += String.fromCharCode.apply( + String, + arr.slice(index, Math.min(index + CHUNKSIZE, len)) + ); + index += CHUNKSIZE; + } + return parts; }; String["fromCodePoints"] = function fromCodePoints(arr) { - return String.fromCodePoint.apply(String, arr); + const CHUNKSIZE = 1 << 13; + const len = arr.length; + if (len <= CHUNKSIZE) { + return String.fromCodePoint.apply(String, arr); + } + let index = 0; + let parts = ''; + while (index < len) { + parts += String.fromCodePoint.apply( + String, + arr.slice(index, Math.min(index + CHUNKSIZE, len)) + ); + index += CHUNKSIZE; + } + return parts; }; if (!String.prototype.replaceAll) {