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..459a351c33 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,17 @@ 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(from: number, to: number, list: ReadonlyArray): T[]; + move(from: number, to: number): (list: ReadonlyArray) => T[]; + move(from: number): { + (to: number, list: ReadonlyArray): T[]; + (to: number): (list: ReadonlyArray) => T[]; + }; + /** * 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..e4039483da 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -1115,6 +1115,23 @@ interface Obj { R.addIndex(R.map)(squareEnds)([8, 5, 3, 0, 9]); // => [64, 5, 3, 0, 81] }; +() => { + 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'] +}; + () => { R.none(R.isNaN, [1, 2, 3]); // => true R.none(R.isNaN, [1, 2, 3, NaN]); // => false