Skip to content

Instantly share code, notes, and snippets.

@rmdort
Created December 16, 2019 12:46
Show Gist options
  • Save rmdort/e07b10c0556e066fd7483b542b5b2f9b to your computer and use it in GitHub Desktop.
Save rmdort/e07b10c0556e066fd7483b542b5b2f9b to your computer and use it in GitHub Desktop.
Array move
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