-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathindex.d.ts
49 lines (37 loc) · 1.59 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
Clones the given `array`, moves the item to a new position in the new array, and then returns the new array. The given `array` is not mutated.
@param array - The array with the item to move.
@param fromIndex - The index of item to move. If negative, it will begin that many elements from the end.
@param toIndex - The index of where to move the item. If negative, it will begin that many elements from the end.
@returns A new array with the item moved to the new position.
@example
```
import {arrayMoveImmutable} from 'array-move';
const input = ['a', 'b', 'c'];
const array1 = arrayMoveImmutable(input, 1, 2);
console.log(array1);
//=> ['a', 'c', 'b']
const array2 = arrayMoveImmutable(input, -1, 0);
console.log(array2);
//=> ['c', 'a', 'b']
const array3 = arrayMoveImmutable(input, -2, -3);
console.log(array3);
//=> ['b', 'a', 'c']
```
*/
export function arrayMoveImmutable<ValueType>(array: readonly ValueType[], fromIndex: number, toIndex: number): ValueType[];
/**
Moves the item to the new position in the input array. Useful for huge arrays where absolute performance is needed.
@param array - The array to modify.
@param fromIndex - The index of the item to move. If negative, it will begin that many elements from the end.
@param toIndex - The index of where to move the item. If negative, it will begin that many elements from the end.
@example
```
import {arrayMoveMutable} from 'array-move';
const input = ['a', 'b', 'c'];
arrayMoveMutable(input, 1, 2);
console.log(input);
//=> ['a', 'c', 'b']
```
*/
export function arrayMoveMutable(array: unknown[], fromIndex: number, toIndex: number): void;