mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Merge pull request #7476 from chrootsu/lodash-sortByOrder
lodash: signatures of _.sortByOrder have been changed
This commit is contained in:
+90
-10
@@ -5093,18 +5093,98 @@ result = <IStoogesAge[]>_.sortByAll(stoogesAges, function(stooge) { return Math.
|
||||
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 = <IFoodOrganic[]>_(foodsOrganic).sortByAll('organic', (food) => food.name, { organic: true }).value();
|
||||
|
||||
// _.sortByOrder
|
||||
module TestSortByOrder {
|
||||
type SampleObject = {a: number; b: string; c: boolean};
|
||||
|
||||
let array: SampleObject[];
|
||||
let list: _.List<SampleObject>;
|
||||
let numericDictionary: _.NumericDictionary<SampleObject>;
|
||||
let dictionary: _.Dictionary<SampleObject>;
|
||||
let orders: boolean|string|(boolean|string)[];
|
||||
|
||||
{
|
||||
let iteratees: (value: string) => any|((value: string) => any)[];
|
||||
let result: string[];
|
||||
|
||||
result = _.sortByOrder<string>('acbd', iteratees);
|
||||
result = _.sortByOrder<string>('acbd', iteratees, orders);
|
||||
}
|
||||
|
||||
{
|
||||
let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[];
|
||||
let result: SampleObject[];
|
||||
|
||||
result = _.sortByOrder<{a: number}, SampleObject>(array, iteratees);
|
||||
result = _.sortByOrder<{a: number}, SampleObject>(array, iteratees, orders);
|
||||
result = _.sortByOrder<SampleObject>(array, iteratees);
|
||||
result = _.sortByOrder<SampleObject>(array, iteratees, orders);
|
||||
|
||||
result = _.sortByOrder<{a: number}, SampleObject>(list, iteratees);
|
||||
result = _.sortByOrder<{a: number}, SampleObject>(list, iteratees, orders);
|
||||
result = _.sortByOrder<SampleObject>(list, iteratees);
|
||||
result = _.sortByOrder<SampleObject>(list, iteratees, orders);
|
||||
|
||||
result = _.sortByOrder<{a: number}, SampleObject>(numericDictionary, iteratees);
|
||||
result = _.sortByOrder<{a: number}, SampleObject>(numericDictionary, iteratees, orders);
|
||||
result = _.sortByOrder<SampleObject>(numericDictionary, iteratees);
|
||||
result = _.sortByOrder<SampleObject>(numericDictionary, iteratees, orders);
|
||||
|
||||
result = _.sortByOrder<{a: number}, SampleObject>(dictionary, iteratees);
|
||||
result = _.sortByOrder<{a: number}, SampleObject>(dictionary, iteratees, orders);
|
||||
result = _.sortByOrder<SampleObject>(dictionary, iteratees);
|
||||
result = _.sortByOrder<SampleObject>(dictionary, iteratees, orders);
|
||||
}
|
||||
|
||||
{
|
||||
let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[];
|
||||
let result: _.LoDashImplicitArrayWrapper<SampleObject>;
|
||||
|
||||
result = _(array).sortByOrder<{a: number}>(iteratees);
|
||||
result = _(array).sortByOrder<{a: number}>(iteratees, orders);
|
||||
|
||||
result = _(list).sortByOrder<{a: number}, SampleObject>(iteratees);
|
||||
result = _(list).sortByOrder<{a: number}, SampleObject>(iteratees, orders);
|
||||
result = _(list).sortByOrder<SampleObject>(iteratees);
|
||||
result = _(list).sortByOrder<SampleObject>(iteratees, orders);
|
||||
|
||||
result = _(numericDictionary).sortByOrder<{a: number}, SampleObject>(iteratees);
|
||||
result = _(numericDictionary).sortByOrder<{a: number}, SampleObject>(iteratees, orders);
|
||||
result = _(numericDictionary).sortByOrder<SampleObject>(iteratees);
|
||||
result = _(numericDictionary).sortByOrder<SampleObject>(iteratees, orders);
|
||||
|
||||
result = _(dictionary).sortByOrder<{a: number}, SampleObject>(iteratees);
|
||||
result = _(dictionary).sortByOrder<{a: number}, SampleObject>(iteratees, orders);
|
||||
result = _(dictionary).sortByOrder<SampleObject>(iteratees);
|
||||
result = _(dictionary).sortByOrder<SampleObject>(iteratees, orders);
|
||||
}
|
||||
|
||||
{
|
||||
let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[];
|
||||
let result: _.LoDashExplicitArrayWrapper<SampleObject>;
|
||||
|
||||
result = _(array).chain().sortByOrder<{a: number}>(iteratees);
|
||||
result = _(array).chain().sortByOrder<{a: number}>(iteratees, orders);
|
||||
|
||||
result = _(list).chain().sortByOrder<{a: number}, SampleObject>(iteratees);
|
||||
result = _(list).chain().sortByOrder<{a: number}, SampleObject>(iteratees, orders);
|
||||
result = _(list).chain().sortByOrder<SampleObject>(iteratees);
|
||||
result = _(list).chain().sortByOrder<SampleObject>(iteratees, orders);
|
||||
|
||||
result = _(numericDictionary).chain().sortByOrder<{a: number}, SampleObject>(iteratees);
|
||||
result = _(numericDictionary).chain().sortByOrder<{a: number}, SampleObject>(iteratees, orders);
|
||||
result = _(numericDictionary).chain().sortByOrder<SampleObject>(iteratees);
|
||||
result = _(numericDictionary).chain().sortByOrder<SampleObject>(iteratees, orders);
|
||||
|
||||
result = _(dictionary).chain().sortByOrder<{a: number}, SampleObject>(iteratees);
|
||||
result = _(dictionary).chain().sortByOrder<{a: number}, SampleObject>(iteratees, orders);
|
||||
result = _(dictionary).chain().sortByOrder<SampleObject>(iteratees);
|
||||
result = _(dictionary).chain().sortByOrder<SampleObject>(iteratees, orders);
|
||||
}
|
||||
}
|
||||
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'age': 40 });
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'quotes': ['Poifect!'] });
|
||||
|
||||
|
||||
Vendored
+189
-44
@@ -8450,66 +8450,211 @@ declare module _ {
|
||||
//_.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[];
|
||||
* 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 iteratees The iteratees to sort by.
|
||||
* @param orders The sort orders of iteratees.
|
||||
* @return Returns the new sorted array.
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
collection: List<T>,
|
||||
iteratees: ListIterator<T, any>|string|W|(ListIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
collection: List<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: boolean[]): T[];
|
||||
iteratees: ListIterator<T, any>|string|Object|(ListIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
sortByOrder<T>(
|
||||
collection: Array<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: string[]): T[];
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
collection: NumericDictionary<T>,
|
||||
iteratees: NumericDictionaryIterator<T, any>|string|W|(NumericDictionaryIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
collection: List<T>,
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: string[]): T[];
|
||||
collection: NumericDictionary<T>,
|
||||
iteratees: NumericDictionaryIterator<T, any>|string|Object|(NumericDictionaryIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
collection: Dictionary<T>,
|
||||
iteratees: DictionaryIterator<T, any>|string|W|(DictionaryIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
collection: Dictionary<T>,
|
||||
iteratees: DictionaryIterator<T, any>|string|Object|(DictionaryIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): T[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder(
|
||||
iteratees: ListIterator<T, any>|string|(ListIterator<T, any>|string)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
sortByOrder(
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: boolean[]): LoDashImplicitArrayWrapper<T>;
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object>(
|
||||
iteratees: ListIterator<T, any>|string|W|(ListIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
iteratees: ListIterator<T, any>|string|W|(ListIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
**/
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
iteratees: ListIterator<T, any>|string|Object|(ListIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
iteratees: NumericDictionaryIterator<T, any>|string|W|(NumericDictionaryIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
iteratees: NumericDictionaryIterator<T, any>|string|Object|(NumericDictionaryIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
iteratees: DictionaryIterator<T, any>|string|W|(DictionaryIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
iteratees: DictionaryIterator<T, any>|string|Object|(DictionaryIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder(
|
||||
iteratees: (ListIterator<T, any>|string|Object)[],
|
||||
orders?: string[]): LoDashImplicitArrayWrapper<T>;
|
||||
iteratees: ListIterator<T, any>|string|(ListIterator<T, any>|string)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object>(
|
||||
iteratees: ListIterator<T, any>|string|W|(ListIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
iteratees: ListIterator<T, any>|string|W|(ListIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
iteratees: ListIterator<T, any>|string|Object|(ListIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
iteratees: NumericDictionaryIterator<T, any>|string|W|(NumericDictionaryIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
iteratees: NumericDictionaryIterator<T, any>|string|Object|(NumericDictionaryIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<W extends Object, T>(
|
||||
iteratees: DictionaryIterator<T, any>|string|W|(DictionaryIterator<T, any>|string|W)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByOrder
|
||||
*/
|
||||
sortByOrder<T>(
|
||||
iteratees: DictionaryIterator<T, any>|string|Object|(DictionaryIterator<T, any>|string|Object)[],
|
||||
orders?: boolean|string|(boolean|string)[]
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.where
|
||||
|
||||
Reference in New Issue
Block a user