export function arrayMove < T = any > ( array , fromIndex , toIndex ) { fromIndex = clamp ( fromIndex , array . length - 1 ) ; toIndex = clamp ( toIndex , array . length - 1 ) ; if ( fromIndex !== toIndex ) { array . splice ( toIndex , 0 , array . splice ( fromIndex , 1 ) [ 0 ] ) ; } } export function arrayTransfer < T = any > ( arrayFrom , arrayTo , fromIndex , toIndex ) { fromIndex = clamp ( fromIndex , arrayFrom . length - 1 ) ; toIndex = clamp ( toIndex , arrayTo . length ) ; if ( arrayFrom . length ) { arrayTo . splice ( toIndex , 0 , arrayFrom . splice ( fromIndex , 1 ) [ 0 ] ) ; } } function clamp ( a , b ) { return Math . max ( 0 , Math . min ( a , b ) ) ; } export function arrayPaginate < T = any > ( array , currentPage , perPage ) { if ( ! array || ! currentPage || ! perPage ) { return array ; } const start = ( currentPage - 1 ) * perPage ; const end = perPage > - 1 ? ( start + perPage ) : array . length ; return array . slice ( start , end ) ; }