mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-22 11:40:10 +08:00
Merge pull request #5033 from dbeckwith/master
Adds _.sortByAll and _.sortByOrder
This commit is contained in:
@@ -665,6 +665,20 @@ result = <number[]>_.sortBy([1, 2, 3], function (num) { return Math.sin(num); })
|
||||
result = <number[]>_.sortBy([1, 2, 3], function (num) { return this.sin(num); }, Math);
|
||||
result = <string[]>_.sortBy(['banana', 'strawberry', 'apple'], 'length');
|
||||
|
||||
result = <IStoogesAge[]>_.sortByAll(stoogesAges, function(stooge) { return Math.sin(stooge.age); }, function(stooge) { return stooge.name.slice(1); });
|
||||
result = <IStoogesAge[]>_.sortByAll(stoogesAges, ['name', 'age']);
|
||||
result = <IStoogesAge[]>_.sortByAll(stoogesAges, 'name', function(stooge) { return Math.sin(stooge.age); });
|
||||
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, [function(stooge) { return Math.sin(stooge.age); }, function(stooge) { return stooge.name.slice(1); }]);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', 'age']);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', function(stooge) { return Math.sin(stooge.age); }]);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, [function(stooge) { return Math.sin(stooge.age); }, function(stooge) { return stooge.name.slice(1); }], ['asc', 'desc']);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', 'age'], ['asc', 'desc']);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', function(stooge) { return Math.sin(stooge.age); }], ['asc', 'desc']);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, [function(stooge) { return Math.sin(stooge.age); }, function(stooge) { return stooge.name.slice(1); }], [true, false]);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', 'age'], [true, false]);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', function(stooge) { return Math.sin(stooge.age); }], [true, false]);
|
||||
|
||||
result = <number[]>_([1, 2, 3]).sortBy(function (num) { return Math.sin(num); }).value();
|
||||
result = <number[]>_([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, Math).value();
|
||||
result = <string[]>_(['banana', 'strawberry', 'apple']).sortBy('length').value();
|
||||
|
||||
Vendored
+133
-5
@@ -4771,8 +4771,11 @@ declare module _ {
|
||||
*
|
||||
* If a property name is provided for callback the created "_.pluck" style callback will
|
||||
* return the property value of the given element.
|
||||
*
|
||||
* If an object is provided for callback the created "_.where" style callback will return
|
||||
*
|
||||
* If a value is also provided for thisArg the created "_.matchesProperty" style callback
|
||||
* returns true for elements that have a matching property value, else false.
|
||||
*
|
||||
* If an object is provided for an iteratee the created "_.matches" style callback returns
|
||||
* true for elements that have the properties of the given object, else false.
|
||||
* @param collection The collection to iterate over.
|
||||
* @param callback The function called per iteration.
|
||||
@@ -4781,7 +4784,7 @@ declare module _ {
|
||||
**/
|
||||
sortBy<T, TSort>(
|
||||
collection: Array<T>,
|
||||
callback?: ListIterator<T, TSort>,
|
||||
iteratee?: ListIterator<T, TSort>,
|
||||
thisArg?: any): T[];
|
||||
|
||||
/**
|
||||
@@ -4789,7 +4792,7 @@ declare module _ {
|
||||
**/
|
||||
sortBy<T, TSort>(
|
||||
collection: List<T>,
|
||||
callback?: ListIterator<T, TSort>,
|
||||
iteratee?: ListIterator<T, TSort>,
|
||||
thisArg?: any): T[];
|
||||
|
||||
/**
|
||||
@@ -4830,7 +4833,7 @@ declare module _ {
|
||||
* @see _.sortBy
|
||||
**/
|
||||
sortBy<TSort>(
|
||||
callback?: ListIterator<T, TSort>,
|
||||
iteratee?: ListIterator<T, TSort>,
|
||||
thisArg?: any): LoDashArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
@@ -4846,6 +4849,131 @@ declare module _ {
|
||||
sortBy<W>(whereValue: W): LoDashArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.sortByAll
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* This method is like "_.sortBy" except that it can sort by multiple iteratees or
|
||||
* property names.
|
||||
*
|
||||
* If a property name is provided for an iteratee the created "_.property" style callback
|
||||
* returns the property value of the given element.
|
||||
*
|
||||
* If a value is also provided for thisArg the created "_.matchesProperty" style callback
|
||||
* returns true for elements that have a matching property value, else false.
|
||||
*
|
||||
* If an object is provided for an iteratee the created "_.matches" style callback returns
|
||||
* true for elements that have the properties of the given object, else false.
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @param callback The function called per iteration.
|
||||
* @param thisArg The this binding of callback.
|
||||
* @return A new array of sorted elements.
|
||||
**/
|
||||
sortByAll<T>(
|
||||
collection: Array<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[]): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByAll
|
||||
**/
|
||||
sortByAll<T>(
|
||||
collection: List<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[]): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByAll
|
||||
**/
|
||||
sortByAll<T>(
|
||||
collection: Array<T>,
|
||||
...iteratees: (ListIterator<T, any>|string|Object)[]): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByAll
|
||||
**/
|
||||
sortByAll<T>(
|
||||
collection: List<T>,
|
||||
...iteratees: (ListIterator<T, any>|string|Object)[]): T[];
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.sortByAll
|
||||
**/
|
||||
sortByAll(
|
||||
iteratees: (ListIterator<T, any>|string|Object)[]): LoDashArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByAll
|
||||
**/
|
||||
sortByAll(
|
||||
...iteratees: (ListIterator<T, any>|string|Object)[]): LoDashArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.sortByOrder
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* This method is like "_.sortByAll" except that it allows specifying the sort orders of the
|
||||
* iteratees to sort by. If orders is unspecified, all values are sorted in ascending order.
|
||||
* Otherwise, a value is sorted in ascending order if its corresponding order is "asc", and
|
||||
* descending if "desc".
|
||||
*
|
||||
* If a property name is provided for an iteratee the created "_.property" style callback
|
||||
* returns the property value of the given element.
|
||||
*
|
||||
* If an object is provided for an iteratee the created "_.matches" style callback returns
|
||||
* true for elements that have the properties of the given object, else false.
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @param callback The function called per iteration.
|
||||
* @param thisArg The this binding of callback.
|
||||
* @return A new array of sorted elements.
|
||||
**/
|
||||
sortByOrder<T>(
|
||||
collection: Array<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: boolean[]): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
sortByOrder<T>(
|
||||
collection: List<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: boolean[]): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
sortByOrder<T>(
|
||||
collection: Array<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: string[]): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
sortByOrder<T>(
|
||||
collection: List<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: string[]): T[];
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
sortByOrder(
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: boolean[]): LoDashArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
sortByOrder(
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: string[]): LoDashArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.toArray
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user