From 2eb3ca741dbb6ec79af53d0def5c409da43a2dd2 Mon Sep 17 00:00:00 2001 From: Krantisinh Deshmukh Date: Fri, 1 Feb 2019 10:32:21 +0530 Subject: [PATCH] [Ramda] - Added type definition for R.move --- types/ramda/es/move.d.ts | 2 ++ types/ramda/index.d.ts | 8 ++++++++ types/ramda/ramda-tests.ts | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 types/ramda/es/move.d.ts diff --git a/types/ramda/es/move.d.ts b/types/ramda/es/move.d.ts new file mode 100644 index 0000000000..3df4ee626e --- /dev/null +++ b/types/ramda/es/move.d.ts @@ -0,0 +1,2 @@ +import { move } from '../index'; +export default move; diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index d84c148d96..a35b2612ee 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -26,6 +26,7 @@ // Drew Wyatt // John Ottenlips // Nitesh Phadatare +// Krantisinh Deshmukh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -163,6 +164,7 @@ /// /// /// +/// /// /// /// @@ -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; + /** * 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. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index c67ef3944d..abc7b60775 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -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'] +};