mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-25 16:11:24 +08:00
update ramda to include ascend, descend, sortWith functions
This commit is contained in:
23
types/ramda/index.d.ts
vendored
23
types/ramda/index.d.ts
vendored
@@ -212,6 +212,12 @@ declare namespace R {
|
||||
*/
|
||||
applySpec<T>(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<T>(fn: (obj: T) => any, a: T, b: T): number;
|
||||
ascend<T>(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<T,U>(a: T, b: U): T|U
|
||||
defaultTo<T>(a: T): <U>(b: U) => T|U
|
||||
defaultTo<T,U>(a: T, b: U): T|U;
|
||||
defaultTo<T>(a: T): <U>(b: U) => T|U;
|
||||
|
||||
|
||||
/**
|
||||
* Makes a descending comparator function out of a function that returns a value that can be compared with < and >.
|
||||
*/
|
||||
descend<T>(fn: (obj: T) => any, a: T, b: T): number;
|
||||
descend<T>(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<T>(fn: (a: any) => Ord, list: T[]): T[];
|
||||
sortBy(fn: (a: any) => Ord): <T>(list: T[]) => T[];
|
||||
|
||||
/**
|
||||
* Sorts a list according to a list of comparators.
|
||||
*/
|
||||
sortWith<T>(fns: ((a: T, b: T) => number)[], list: T[]): T[];
|
||||
sortWith<T>(fns: ((a: T, b: T) => number)[]): (list: T[]) => T[];
|
||||
|
||||
/**
|
||||
* Splits a string into an array of strings based on the given
|
||||
* separator.
|
||||
|
||||
@@ -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; };
|
||||
|
||||
Reference in New Issue
Block a user