From 5575575c941dfd9b89ea3cc1b11bfd345b70e793 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 13 Oct 2015 03:30:27 +0500 Subject: [PATCH] lodash: signatures of the method _.min have been changed --- lodash/lodash-tests.ts | 55 +++++++++-- lodash/lodash.d.ts | 215 ++++++++++++++++++++--------------------- 2 files changed, 152 insertions(+), 118 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index daa640fcbb..adf86e9a61 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1633,13 +1633,6 @@ result = _(0.046).floor(2); result = _(4060).floor(-2); // → 4000 -result = _.min([4, 2, 8, 6]); -result = _.min(stoogesAges, function (stooge) { return stooge.age; }); -result = _.min(stoogesAges, 'age'); -result = <_.LoDashWrapper>_([4, 2, 8, 6]).min(); -result = <_.LoDashWrapper>_(stoogesAges).min(function (stooge) { return stooge.age; }); -result = <_.LoDashWrapper>_(stoogesAges).min('age'); - // _.round result = _.round(4.006); // → 4 @@ -2500,6 +2493,54 @@ module TestMax { result = _(dictionary).max<{a: number}, number>({a: 42}); } +// _.min +module TestMin { + let array: number[]; + let list: _.List; + let dictionary: _.Dictionary; + + let listIterator: (value: number, index: number, collection: _.List) => number; + let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => number; + + let result: number; + + result = _.min(array); + result = _.min(array, listIterator); + result = _.min(array, listIterator, any); + result = _.min(array, ''); + result = _.min<{a: number}, number>(array, {a: 42}); + + result = _.min(list); + result = _.min(list, listIterator); + result = _.min(list, listIterator, any); + result = _.min(list, ''); + result = _.min<{a: number}, number>(list, {a: 42}); + + result = _.min(dictionary); + result = _.min(dictionary, dictionaryIterator); + result = _.min(dictionary, dictionaryIterator, any); + result = _.min(dictionary, ''); + result = _.min<{a: number}, number>(dictionary, {a: 42}); + + result = _(array).min(); + result = _(array).min(listIterator); + result = _(array).min(listIterator, any); + result = _(array).min(''); + result = _(array).min<{a: number}>({a: 42}); + + result = _(list).min(); + result = _(list).min(listIterator); + result = _(list).min(listIterator, any); + result = _(list).min(''); + result = _(list).min<{a: number}, number>({a: 42}); + + result = _(dictionary).min(); + result = _(dictionary).min(dictionaryIterator); + result = _(dictionary).min(dictionaryIterator, any); + result = _(dictionary).min(''); + result = _(dictionary).min<{a: number}, number>({a: 42}); +} + /********** * Number * **********/ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b2659d0aa6..d5463ffc00 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4370,117 +4370,6 @@ declare module _ { floor(precision?: number): number; } - //_.min - interface LoDashStatic { - /** - * Retrieves the minimum value of a collection. If the collection is empty or falsey - * Infinity is returned. If a callback is provided it will be executed for each value - * in the collection to generate the criterion by which the value is ranked. The callback - * is bound to thisArg and invoked with three arguments; (value, index, collection). - * - * 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 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 Returns the maximum value. - **/ - min( - collection: Array, - callback?: ListIterator, - thisArg?: any): T; - - /** - * @see _.min - **/ - min( - collection: List, - callback?: ListIterator, - thisArg?: any): T; - - /** - * @see _.min - **/ - min( - collection: Dictionary, - callback?: ListIterator, - thisArg?: any): T; - - /** - * @see _.min - * @param pluckValue _.pluck style callback - **/ - min( - collection: Array, - pluckValue: string): T; - - /** - * @see _.min - * @param pluckValue _.pluck style callback - **/ - min( - collection: List, - pluckValue: string): T; - - /** - * @see _.min - * @param pluckValue _.pluck style callback - **/ - min( - collection: Dictionary, - pluckValue: string): T; - - /** - * @see _.min - * @param whereValue _.where style callback - **/ - min( - collection: Array, - whereValue: W): T; - - /** - * @see _.min - * @param whereValue _.where style callback - **/ - min( - collection: List, - whereValue: W): T; - - /** - * @see _.min - * @param whereValue _.where style callback - **/ - min( - collection: Dictionary, - whereValue: W): T; - } - - interface LoDashArrayWrapper { - /** - * @see _.min - **/ - min( - callback?: ListIterator, - thisArg?: any): LoDashWrapper; - - /** - * @see _.min - * @param pluckValue _.pluck style callback - **/ - min( - pluckValue: string): LoDashWrapper; - - /** - * @see _.min - * @param whereValue _.where style callback - **/ - min( - whereValue: W): LoDashWrapper; - } - //_.round interface LoDashStatic { /** @@ -7324,6 +7213,110 @@ declare module _ { ): T; } + //_.min + interface LoDashStatic { + /** + * Gets the minimum value of collection. If collection is empty or falsey Infinity is returned. If an iteratee + * function is provided it’s invoked for each value in collection to generate the criterion by which the value + * is ranked. The iteratee is bound to thisArg and invoked with three arguments: (value, index, collection). + * + * If a property name is provided for 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 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 iteratee The function invoked per iteration. + * @param thisArg The this binding of iteratee. + * @return Returns the minimum value. + */ + min( + collection: List, + iteratee?: ListIterator, + thisArg?: any + ): T; + + /** + * @see _.min + */ + min( + collection: Dictionary, + iteratee?: DictionaryIterator, + thisArg?: any + ): T; + + /** + * @see _.min + */ + min( + collection: List|Dictionary, + iteratee?: string, + thisArg?: any + ): T; + + /** + * @see _.min + */ + min( + collection: List|Dictionary, + whereValue?: TObject + ): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.min + */ + min( + iteratee?: ListIterator, + thisArg?: any + ): T; + + /** + * @see _.min + */ + min( + iteratee?: string, + thisArg?: any + ): T; + + /** + * @see _.min + */ + min( + whereValue?: TObject + ): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.min + */ + min( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): T; + + /** + * @see _.min + */ + min( + iteratee?: string, + thisArg?: any + ): T; + + /** + * @see _.min + */ + min( + whereValue?: TObject + ): T; + } + /********** * Number * **********/