Merge pull request #17095 from xiongemi/update-ramda-to-024

update ramda to include ascend, descend, sortWith functions
This commit is contained in:
Mine Starks
2017-06-15 13:17:50 -07:00
committed by GitHub
2 changed files with 29 additions and 2 deletions
+21 -2
View File
@@ -251,6 +251,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.
*/
@@ -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<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.
@@ -1450,6 +1463,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.
+8
View File
@@ -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; };