array-move
Advanced tools
Comparing version 0.1.0 to 1.0.0
'use strict'; | ||
function arrayMove(x, from, to) { | ||
x.splice(to, 0, x.splice(from, 1)[0]); | ||
x.splice((to < 0 ? x.length + to : to), 0, x.splice(from, 1)[0]); | ||
} | ||
@@ -6,0 +6,0 @@ |
{ | ||
"name": "array-move", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Move an array item to a different position", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -18,7 +18,12 @@ # array-move [![Build Status](https://travis-ci.org/sindresorhus/array-move.svg?branch=master)](https://travis-ci.org/sindresorhus/array-move) | ||
arrayMove(['a', 'b', 'c'], 1, 2); | ||
var input = ['a', 'b', 'c']; | ||
arrayMove(input, 1, 2); | ||
//=> ['a', 'c', 'b'] | ||
arrayMove(['a', 'b', 'c'], -1, 0); | ||
arrayMove(input, -1, 0); | ||
//=> ['c', 'a', 'b'] | ||
arrayMove(input, -2, -3); | ||
//=> ['b', 'a', 'c'] | ||
``` | ||
@@ -53,3 +58,4 @@ | ||
Index of where to move the item. | ||
Index of where to move the item. | ||
If negative, it will begin that many elements from the end. | ||
@@ -56,0 +62,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2993
1
64