Skip to content

Commit d18037c

Browse files
committed
make insertAt able to insert multiple elements
1 parent 2d3b861 commit d18037c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import typescript from 'rollup-plugin-typescript2';
2020
const getLastElement = array => {
2121
return array[array.length - 1];
2222
};
23-
export const insertAt = (arr, index, insertee) => {
23+
export const insertAt = (arr, index, ...insertees) => {
2424
const newArr = [...arr];
2525
// Add 1 to the array length so that the inserted element ends up in the right spot with respect to the length of the
2626
// new array (which will be one element longer), rather than that of the current array
2727
const destinationIndex = index >= 0 ? index : arr.length + 1 + index;
28-
newArr.splice(destinationIndex, 0, insertee);
28+
newArr.splice(destinationIndex, 0, ...insertees);
2929
return newArr;
3030
};
3131

0 commit comments

Comments
 (0)