Skip to content

Commit acc135e

Browse files
committed
Refactor to omit spread operator that crashes
Closes micromarkGH-187.
1 parent dd1bbe0 commit acc135e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/micromark-util-subtokenize/dev/lib/splice-buffer.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {constants} from 'micromark-util-symbol'
1010
* proportional to the number of elements added or removed, whereas
1111
* other operations (shift/unshift and splice) are much less efficient.
1212
* - Function arguments are passed on the stack, so adding tens of thousands
13-
* of elements to an array with `arr.push[...newElements]` will frequently
13+
* of elements to an array with `arr.push(...newElements)` will frequently
1414
* cause stack overflows. (see <https://stackoverflow.com/questions/22123769/rangeerror-maximum-call-stack-size-exceeded-why>)
1515
*
1616
* SpliceBuffers are an implementation of gap buffers, which are a
@@ -116,13 +116,11 @@ export class SpliceBuffer {
116116
.reverse()
117117
}
118118

119-
const list = this.left.slice(start)
120-
121-
list.push(
122-
...this.right.slice(this.right.length - stop + this.left.length).reverse()
123-
)
124-
125-
return list
119+
return this.left
120+
.slice(start)
121+
.concat(
122+
this.right.slice(this.right.length - stop + this.left.length).reverse()
123+
)
126124
}
127125

128126
/**

0 commit comments

Comments
 (0)