license param array param fromIndex param toIndex export function moveItemInArray < T = any > ( array , fromIndex , toIndex ) { const from = clamp ( fromIndex , array . length - 1 ) ; const to = clamp ( toIndex , array . length - 1 ) ; if ( from === to ) { return ; } const target = array [ from ] ; const delta = to < from ? - 1 : 1 ; for ( let i = from ; i !== to ; i += delta ) { array [ i ] = array [ i + delta ] ; } array [ to ] = target ; } param currentArray param targetArray param currentIndex param targetIndex export function transferArrayItem < T = any > ( currentArray , targetArray , currentIndex , targetIndex ) { const from = clamp ( currentIndex , currentArray . length - 1 ) ; const to = clamp ( targetIndex , targetArray . length ) ; if ( currentArray . length ) { targetArray . splice ( to , 0 , currentArray . splice ( from , 1 ) [ 0 ] ) ; } } param currentArray param targetArray param currentIndex param targetIndex export function copyArrayItem < T = any > ( currentArray , targetArray , currentIndex , targetIndex ) { const to = clamp ( targetIndex , targetArray . length ) ; if ( currentArray . length ) { targetArray . splice ( to , 0 , currentArray [ currentIndex ] ) ; } } /** Clamps a number between zero and a maximum. */ function clamp ( value , max ) { return Math . max ( 0 , Math . min ( max , value ) ) ; }