array-modifier
v1.2.0
Published
Javascript plugin for modifying array
Readme
array-modifier
Installation
npm install array-modifierProvided functionalities
- Swap elemets in an array (swapElement).
- Move elements in an array (moveElements)
swapElement
Function accepts array, from index and To index and return swaped array.
swapElement(array[],2,3)Usage
import {swapElement} from 'array-modifier';
console.log(swapElement(['mango','apple','orange'],0,2))Response
['orange','apple','mango']moveElements
Function that helps to move an object in an array from one index to another index. Function accepts array list, from index and To index and return rearranged array.
moveElements (arrayList, fromIndex, toIndex)Usage
import {moveElements} from 'array-modifier';
let arrayList = ['mango', 'banana', 'apple', 'orange'];
console.log(moveElements(arrayList, 2, 0))Result
["apple", "mango", "banana", "orange"]