GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - m1oto/array-move: Move an array item to a different position

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
index.js
index.js
 
 
license
license
 
 
package.json
package.json
 
 
readme.md
readme.md
 
 
test.js
test.js
 
 

Repository files navigation

array-move Build Status

Move an array item to a different position

Install

$ npm install --save array-move

Usage

const arrayMove = require('array-move');

const input = ['a', 'b', 'c'];

arrayMove(input, 1, 2);
//=> ['a', 'c', 'b']

arrayMove(input, -1, 0);
//=> ['c', 'a', 'b']

arrayMove(input, -2, -3);
//=> ['b', 'a', 'c']

API

arrayMove(input, from, to)

Returns a new array with the item moved to the new position.

arrayMove.mut(input, from, to)

Moves the item to the new position in the input array.
Useful for huge arrays where absolute performance is needed.

input

Type: array

from

Type: number

Index of item to move.
If negative, it will begin that many elements from the end.

to

Type: number

Index of where to move the item.
If negative, it will begin that many elements from the end.

License

MIT © Sindre Sorhus

About

Move an array item to a different position

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.