rQshiftStr: function (len) {
if (typeof(len) === 'undefined') { len = this.rQlen(); }
- const arr = new Uint8Array(this._rQ.buffer, this._rQi, len);
- this._rQi += len;
- return String.fromCharCode.apply(null, arr);
+ const arr = this.rQshiftBytes(len);
+ let str = "";
+ // Handle large arrays in steps to avoid long strings on the stack
+ for (let i = 0; i < len; i += 4096) {
+ let part = arr.slice(i, i + Math.min(4096, len));
+ str = str.concat(String.fromCharCode.apply(null, part));
+ }
+ return str;
},
rQshiftBytes: function (len) {