Package Exports
- array-move-item
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (array-move-item) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
array-move-item
Move an array item to a different position within array bounds
Install
$ npm install --save array-move-itemAPI
moveItem(array, fromIndex, toIndex)
Returns a new array with the item moved to the new position.
If the target index is greater than the length of the array, the item is moved to the end of the array.
If the target index is negative and greater than the length of the array, the item is moved to the start of the array.
Usage
var moveItem = require('array-move-item');
const items = ['a', 'b', 'c'];
moveItem(items, 1, 2);
//=> ['a', 'c', 'b']
moveItem(items, -1, 0);
//=> ['c', 'a', 'b']
moveItem(items, -2, -10);
//=> ['b', 'a', 'c']License
MIT © Illarion Koperski