From 901e24cc8540866b1fbc1fb3f537d17e868d667c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 13 Jan 2016 02:22:46 +0500 Subject: [PATCH] lodash: signatures of _.sortByAll have been changed --- lodash/lodash-tests.ts | 68 ++++++++++++- lodash/lodash.d.ts | 218 +++++++++++++++++++++++++++++++---------- 2 files changed, 228 insertions(+), 58 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4dfaa33f1..f97b1cbc8 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5230,11 +5230,71 @@ module TestSortBy { } } -result = _.sortByAll(stoogesAges, function(stooge) { return Math.sin(stooge.age); }, function(stooge) { return stooge.name.slice(1); }); -result = _.sortByAll(stoogesAges, ['name', 'age']); -result = _.sortByAll(stoogesAges, 'name', function(stooge) { return Math.sin(stooge.age); }); +// _.sortByAll +module TestSortByAll { + type SampleObject = {a: number; b: string; c: boolean}; -result = _(foodsOrganic).sortByAll('organic', (food) => food.name, { organic: true }).value(); + let array: SampleObject[]; + let list: _.List; + let numericDictionary: _.NumericDictionary; + let dictionary: _.Dictionary;; + + { + let iteratees: (value: string) => any|((value: string) => any)[]; + let result: string[]; + + result = _.sortByAll('acbd', iteratees); + } + + { + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[]; + let result: SampleObject[]; + + result = _.sortByAll<{a: number}, SampleObject>(array, iteratees); + result = _.sortByAll(array, iteratees); + + result = _.sortByAll<{a: number}, SampleObject>(list, iteratees); + result = _.sortByAll(list, iteratees); + + result = _.sortByAll<{a: number}, SampleObject>(numericDictionary, iteratees); + result = _.sortByAll(numericDictionary, iteratees); + + result = _.sortByAll<{a: number}, SampleObject>(dictionary, iteratees); + result = _.sortByAll(dictionary, iteratees); + } + + { + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[]; + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).sortByAll<{a: number}>(iteratees); + + result = _(list).sortByAll<{a: number}, SampleObject>(iteratees); + result = _(list).sortByAll(iteratees); + + result = _(numericDictionary).sortByAll<{a: number}, SampleObject>(iteratees); + result = _(numericDictionary).sortByAll(iteratees); + + result = _(dictionary).sortByAll<{a: number}, SampleObject>(iteratees); + result = _(dictionary).sortByAll(iteratees); + } + + { + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[]; + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().sortByAll<{a: number}>(iteratees); + + result = _(list).chain().sortByAll<{a: number}, SampleObject>(iteratees); + result = _(list).chain().sortByAll(iteratees); + + result = _(numericDictionary).chain().sortByAll<{a: number}, SampleObject>(iteratees); + result = _(numericDictionary).chain().sortByAll(iteratees); + + result = _(dictionary).chain().sortByAll<{a: number}, SampleObject>(iteratees); + result = _(dictionary).chain().sortByAll(iteratees); + } +} // _.sortByOrder module TestSortByOrder { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 5f0c07777..662f1366a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -8517,76 +8517,186 @@ declare module _ { //_.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( - collection: Array, - iteratees: (ListIterator|string|Object)[]): T[]; - - /** - * @see _.sortByAll - **/ - sortByAll( + * 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 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, specified as individual values or arrays of values. + * @return Returns the new sorted array. + */ + sortByAll( collection: List, - iteratees: (ListIterator|string|Object)[]): T[]; + iteratees: ListIterator|string|W|(ListIterator|string|W)[] + ): T[]; /** - * @see _.sortByAll - **/ - sortByAll( - collection: Array, - ...iteratees: (ListIterator|string|Object)[]): T[]; - - /** - * @see _.sortByAll - **/ - sortByAll( - collection: List, - ...iteratees: (ListIterator|string|Object)[]): T[]; - - /** - * Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts - * @param args The rules by which to sort + * @see _.sortByAll */ sortByAll( - collection: (Array|List), - ...args: (ListIterator|Object|string)[] + collection: List, + iteratees: ListIterator|string|Object|(ListIterator|string|Object)[] ): T[]; + + /** + * @see _.sortByAll + */ + sortByAll( + collection: NumericDictionary, + iteratees: NumericDictionaryIterator|string|W|(NumericDictionaryIterator|string|W)[] + ): T[]; + + /** + * @see _.sortByAll + */ + sortByAll( + collection: NumericDictionary, + iteratees: NumericDictionaryIterator|string|Object|(NumericDictionaryIterator|string|Object)[] + ): T[]; + + /** + * @see _.sortByAll + */ + sortByAll( + collection: Dictionary, + iteratees: DictionaryIterator|string|W|(DictionaryIterator|string|W)[] + ): T[]; + + /** + * @see _.sortByAll + */ + sortByAll( + collection: Dictionary, + iteratees: DictionaryIterator|string|Object|(DictionaryIterator|string|Object)[] + ): T[]; + } + + interface LoDashImplicitWrapper { + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: ListIterator|string|(ListIterator|string)[] + ): LoDashImplicitArrayWrapper; } interface LoDashImplicitArrayWrapper { /** - * Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts - * @param args The rules by which to sort + * @see _.sortByAll */ - sortByAll(...args: (ListIterator|Object|string)[]): LoDashImplicitArrayWrapper; + sortByAll( + iteratees: ListIterator|string|W|(ListIterator|string|W)[] + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: ListIterator|string|W|(ListIterator|string|W)[] + ): LoDashImplicitArrayWrapper; /** - * @see _.sortByAll - **/ - sortByAll( - iteratees: (ListIterator|string|Object)[]): LoDashImplicitArrayWrapper; + * @see _.sortByAll + */ + sortByAll( + iteratees: ListIterator|string|Object|(ListIterator|string|Object)[] + ): LoDashImplicitArrayWrapper; /** - * @see _.sortByAll - **/ + * @see _.sortByAll + */ + sortByAll( + iteratees: NumericDictionaryIterator|string|W|(NumericDictionaryIterator|string|W)[] + ): LoDashImplicitArrayWrapper; + + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: NumericDictionaryIterator|string|Object|(NumericDictionaryIterator|string|Object)[] + ): LoDashImplicitArrayWrapper; + + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: DictionaryIterator|string|W|(DictionaryIterator|string|W)[] + ): LoDashImplicitArrayWrapper; + + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: DictionaryIterator|string|Object|(DictionaryIterator|string|Object)[] + ): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitWrapper { + /** + * @see _.sortByAll + */ sortByAll( - ...iteratees: (ListIterator|string|Object)[]): LoDashImplicitArrayWrapper; + iteratees: ListIterator|string|(ListIterator|string)[] + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: ListIterator|string|W|(ListIterator|string|W)[] + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: ListIterator|string|W|(ListIterator|string|W)[] + ): LoDashExplicitArrayWrapper; + + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: ListIterator|string|Object|(ListIterator|string|Object)[] + ): LoDashExplicitArrayWrapper; + + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: NumericDictionaryIterator|string|W|(NumericDictionaryIterator|string|W)[] + ): LoDashExplicitArrayWrapper; + + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: NumericDictionaryIterator|string|Object|(NumericDictionaryIterator|string|Object)[] + ): LoDashExplicitArrayWrapper; + + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: DictionaryIterator|string|W|(DictionaryIterator|string|W)[] + ): LoDashExplicitArrayWrapper; + + /** + * @see _.sortByAll + */ + sortByAll( + iteratees: DictionaryIterator|string|Object|(DictionaryIterator|string|Object)[] + ): LoDashExplicitArrayWrapper; } //_.sortByOrder