Created
December 16, 2019 12:46
-
-
Save rmdort/e07b10c0556e066fd7483b542b5b2f9b to your computer and use it in GitHub Desktop.
Array move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function move<T>( | |
source: Array<T>, | |
destination: Array<T>, | |
droppableSource: number, | |
droppableDestination: number | |
) { | |
const sourceClone = Array.from(source); | |
const destClone = Array.from(destination); | |
const [removed] = sourceClone.splice(droppableSource, 1); | |
destClone.splice(droppableDestination, 0, removed); | |
return [sourceClone, destClone]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment