🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

array-move-item

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-move-item

Move an array item to a different position within array bounds

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

array-move-item

Move an array item to a different position within array bounds

Install

$ npm install --save array-move-item

API

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

Keywords

array

FAQs

Package last updated on 17 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts