[Ramda] - Improved type signatures of R.move.

This commit is contained in:
Krantisinh Deshmukh
2019-02-04 12:57:43 +05:30
parent fe88e628b8
commit fff62884ca
2 changed files with 8 additions and 10 deletions
+4 -2
View File
@@ -1578,10 +1578,12 @@ declare namespace R {
multiply(a: number): (b: number) => number;
/**
* Moves an item, at index `from`, to index `to`, in a list of elements.
* Moves an item, at index `from`, to index `to`, in a `list` of elements.
* A new list will be created containing the new elements order.
*/
move: CurriedFunction3<number, number, any[], any[]>;
move<T>(from: number, to: number, list: ReadonlyArray<T>): T[];
move(from: number, to: number): <T>(list: ReadonlyArray<T>) => T[];
move(from: number): (<T>(to: number, list: ReadonlyArray<T>) => T[]);
/**
* Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters.
+4 -8
View File
@@ -1118,18 +1118,14 @@ interface Obj {
() => {
const sampleList = ['a', 'b', 'c', 'd', 'e', 'f'];
R.move(0, 2, sampleList); // => ['b', 'c', 'a', 'd', 'e', 'f']
R.move(-1, 0, sampleList); // => ['f', 'a', 'b', 'c', 'd', 'e'] list rotation
R.move<string>(0, 2, sampleList); // => ['b', 'c', 'a', 'd', 'e', 'f']
R.move<string>(-1, 0, sampleList); // => ['f', 'a', 'b', 'c', 'd', 'e'] list rotation
const moveCurried1 = R.move(0, 2);
moveCurried1(sampleList); // => ['b', 'c', 'a', 'd', 'e', 'f']
moveCurried1<string>(sampleList); // => ['b', 'c', 'a', 'd', 'e', 'f']
const moveCurried2 = R.move(0);
moveCurried2(2, sampleList); // => ['b', 'c', 'a', 'd', 'e', 'f']
const moveCurried3 = R.move(0);
const moveCurried4 = moveCurried3(2);
moveCurried4(sampleList); // => ['b', 'c', 'a', 'd', 'e', 'f']
moveCurried2<string>(2, sampleList); // => ['b', 'c', 'a', 'd', 'e', 'f']
};
() => {