mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 08:42:08 +10:00
initial commit, completed 40% of first milestone
This commit is contained in:
11
src/utils/index.js
Normal file
11
src/utils/index.js
Normal file
@ -0,0 +1,11 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
|
||||
const move = (array, element, delta) => {
|
||||
const index = array.indexOf(element);
|
||||
const newIndex = index + delta;
|
||||
if (newIndex < 0 || newIndex === array.length) return;
|
||||
const indexes = [index, newIndex].sort((a, b) => a - b);
|
||||
array.splice(indexes[0], 2, array[indexes[1]], array[indexes[0]]);
|
||||
};
|
||||
|
||||
export { move };
|
||||
Reference in New Issue
Block a user