parent
562f91f61c
commit
a70ddebc8a
|
@ -1,22 +0,0 @@
|
|||
/**
|
||||
* Move array item from provided index to specified index
|
||||
* @remarks 'to' index refers to position in original array, i.e. if to > from, to = to -1
|
||||
* @param array
|
||||
* @param from - the index of the item we want moved
|
||||
* @param to - the index we want the item moved to
|
||||
* @returns The modified array
|
||||
*
|
||||
* @beta
|
||||
*/
|
||||
export function relocateArrayItem(array: Array<any>, from: number, to: number) {
|
||||
const newArray = structuredClone(array)
|
||||
const element = newArray.splice(from, 1)[0]
|
||||
newArray.splice(to < from ? to : to - 1, 0, element)
|
||||
console.log("reordered array: ")
|
||||
console.log(newArray)
|
||||
return newArray
|
||||
}
|
||||
/**
|
||||
* Returns a complete tmdb image url
|
||||
*/
|
||||
|
Loading…
Reference in New Issue