Moves a particular item in an array up or down (move>0=down, move<0=up). Changes the array itself.
const array = ['a', 'b', 'c'];arrayMoveItem(array, 'a', +1); //['b', 'a', 'c']arrayMoveItem(array, 'a', -1); //['a', 'b', 'c']arrayMoveItem(array, 'b', -1); //['b', 'a', 'c']arrayMoveItem(array, 'b', +1); //['a', 'c', 'b']arrayMoveItem(array, 'c', -1); //['b', 'c', 'b']arrayMoveItem(array, 'c', +1); //['a', 'b', 'c']
Generated using TypeDoc
Moves a particular item in an array up or down (move>0=down, move<0=up). Changes the array itself.