| 1 |
/** |
| 2 |
* Move array element from one index to another. |
| 3 |
* |
| 4 |
* @param {Array} arr - array. |
| 5 |
* @param {Int} fromIndex - from index. |
| 6 |
* @param {Int} toIndex - to index. |
| 7 |
* |
| 8 |
* @return {Array} |
| 9 |
*/ |
| 10 |
export default function arrayMove(arr, fromIndex, toIndex) { |
| 11 |
const element = arr[fromIndex]; |
| 12 |
|
| 13 |
arr.splice(fromIndex, 1); |
| 14 |
arr.splice(toIndex, 0, element); |
| 15 |
|
| 16 |
return arr; |
| 17 |
} |
| 18 |
|