diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 9666c1b78f..3b4bcf098e 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -212,6 +212,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. */ @@ -416,8 +422,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. @@ -1406,6 +1419,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 f9b272f8ca..755a5db06c 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -1517,6 +1517,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; };