const move = ( array , index , delta ) => { 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 ] ] ) ; } ; const moveUp = ( array , toMove ) => { move ( array , toMove , - 1 ) ; } ; const moveDown = ( array , toMove ) => { move ( array , toMove , 1 ) ; } ; export { moveUp , moveDown } ;