diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 4d6be6138f..eb1d873204 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -251,6 +251,12 @@ declare namespace R { */ applySpec(obj: any): (...args: any[]) => T; + /** + * Makes an ascending comparator function out of a function that returns a value that can be compared with < and >. + */ + ascend(fn: (obj: T) => any, a: T, b: T): number; + ascend(fn: (obj: T) => any): (a: T, b: T) => number; + /** * Makes a shallow clone of an object, setting or overriding the specified property with the given value. */ @@ -460,8 +466,15 @@ declare namespace R { * Returns the second argument if it is not null or undefined. If it is null or undefined, the * first (default) argument is returned. */ - defaultTo(a: T, b: U): T|U - defaultTo(a: T): (b: U) => T|U + defaultTo(a: T, b: U): T|U; + defaultTo(a: T): (b: U) => T|U; + + + /** + * Makes a descending comparator function out of a function that returns a value that can be compared with < and >. + */ + descend(fn: (obj: T) => any, a: T, b: T): number; + descend(fn: (obj: T) => any): (a: T, b: T) => number; /** * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. @@ -1450,6 +1463,12 @@ declare namespace R { sortBy(fn: (a: any) => Ord, list: T[]): T[]; sortBy(fn: (a: any) => Ord): (list: T[]) => T[]; + /** + * Sorts a list according to a list of comparators. + */ + sortWith(fns: ((a: T, b: T) => number)[], list: T[]): T[]; + sortWith(fns: ((a: T, b: T) => number)[]): (list: T[]) => T[]; + /** * Splits a string into an array of strings based on the given * separator. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 8fbbb5c7ba..335a86a989 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -1536,6 +1536,14 @@ class Rectangle { R.sort(cmp, people); } +() => { + var people = [ + {name: 'Agy', age:33}, {name: 'Bib', age: 15}, {name: 'Cari', age: 16} + ]; + + R.sortWith([R.ascend(R.prop('age')), R.descend(R.prop('name'))], people); +} + () => { var add = function(a: number, b: number) { return a + b; }; var multiply = function(a: number, b: number) { return a * b; };