frontPanel/src/pages/Questions/DraggableList/helper.ts

12 lines
239 B
TypeScript
Raw Normal View History

2023-08-11 07:25:28 +00:00
export const reorder = <T>(
list: T[],
startIndex: number,
endIndex: number
): T[] => {
const result = Array.from(list);
const [removed] = result.splice(startIndex, 1);
result.splice(endIndex, 0, removed);
return result;
};