This commit is contained in:
16
node_modules/array-move/index.js
generated
vendored
Normal file
16
node_modules/array-move/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export function arrayMoveMutable(array, fromIndex, toIndex) {
|
||||
const startIndex = fromIndex < 0 ? array.length + fromIndex : fromIndex;
|
||||
|
||||
if (startIndex >= 0 && startIndex < array.length) {
|
||||
const endIndex = toIndex < 0 ? array.length + toIndex : toIndex;
|
||||
|
||||
const [item] = array.splice(fromIndex, 1);
|
||||
array.splice(endIndex, 0, item);
|
||||
}
|
||||
}
|
||||
|
||||
export function arrayMoveImmutable(array, fromIndex, toIndex) {
|
||||
array = [...array];
|
||||
arrayMoveMutable(array, fromIndex, toIndex);
|
||||
return array;
|
||||
}
|
||||
Reference in New Issue
Block a user