🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

array-move

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-move

Move an array item to a different position

4.0.0
latest
Source
npm
Version published
Weekly downloads
269K
-23.68%
Maintainers
1
Weekly downloads
 
Created

What is array-move?

The `array-move` npm package allows you to move an item in an array from one position to another. This can be useful for reordering lists or managing the positions of elements in an array.

What are array-move's main functionalities?

Move an item within an array

This feature allows you to move an item from one index to another within the same array. In this example, the item at index 1 ('b') is moved to index 2.

const arrayMove = require('array-move');
const input = ['a', 'b', 'c'];
const result = arrayMove(input, 1, 2);
console.log(result); // ['a', 'c', 'b']

Move an item to the start of an array

This feature allows you to move an item to the start of the array. In this example, the item at index 2 ('c') is moved to index 0.

const arrayMove = require('array-move');
const input = ['a', 'b', 'c'];
const result = arrayMove(input, 2, 0);
console.log(result); // ['c', 'a', 'b']

Move an item to the end of an array

This feature allows you to move an item to the end of the array. In this example, the item at index 0 ('a') is moved to index 2.

const arrayMove = require('array-move');
const input = ['a', 'b', 'c'];
const result = arrayMove(input, 0, 2);
console.log(result); // ['b', 'c', 'a']

Other packages similar to array-move

Keywords

array

FAQs

Package last updated on 10 Aug 2021

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