From 735a19cda3f57aa3572b5e90e404a8502a6d3993 Mon Sep 17 00:00:00 2001 From: Ahmed Zamil Date: Sun, 18 Sep 2022 07:17:22 +0300 Subject: [PATCH] Bad Spread operator --- src/Data/BinaryList.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Data/BinaryList.js b/src/Data/BinaryList.js index 171cd32..0b37adc 100644 --- a/src/Data/BinaryList.js +++ b/src/Data/BinaryList.js @@ -73,9 +73,16 @@ export default class BinaryList } addDC(value) { - this.list.push(...value); + // this is bad, will cause Maximum stack execution exception for large arrays + // this.list.push(...value); + // Fixed + this.list = this.list.concat(Array.from(value)); return this; } + + insertDC(position, value){ + this.list = this.list.slice(0, position).concat(value).concat(this.list.slice(position)); + } insertUint8Array(position, value) { this.insertDC(position, value);