[Ramda] - Added type definition for R.move

This commit is contained in:
Krantisinh Deshmukh 2019-02-01 10:32:21 +05:30
parent f1eed296d2
commit 2eb3ca741d
3 changed files with 27 additions and 0 deletions

2
types/ramda/es/move.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import { move } from '../index';
export default move;

View File

@ -26,6 +26,7 @@
// Drew Wyatt <https://github.com/drewwyatt>
// John Ottenlips <https://github.com/jottenlips>
// Nitesh Phadatare <https://github.com/minitesh>
// Krantisinh Deshmukh <https://github.com/krantisinh>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@ -163,6 +164,7 @@
/// <reference path="./es/minBy.d.ts" />
/// <reference path="./es/min.d.ts" />
/// <reference path="./es/modulo.d.ts" />
/// <reference path="./es/move.d.ts" />
/// <reference path="./es/multiply.d.ts" />
/// <reference path="./es/nAry.d.ts" />
/// <reference path="./es/negate.d.ts" />
@ -1575,6 +1577,12 @@ declare namespace R {
multiply(a: number, b: number): number;
multiply(a: number): (b: number) => number;
/**
* 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[]>;
/**
* Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters.
* Any extraneous parameters will not be passed to the supplied function.

View File

@ -2762,3 +2762,20 @@ class Why {
() => {
R.bind(console.log, console);
};
() => {
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
const moveCurried1 = R.move(0, 2);
moveCurried1(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']
};