lodash: signatures of the method _.min have been changed

This commit is contained in:
Ilya Mochalov 2015-10-13 03:30:27 +05:00
parent 0b1df1ca5f
commit 5575575c94
2 changed files with 152 additions and 118 deletions

View File

@ -1633,13 +1633,6 @@ result = <number>_(0.046).floor(2);
result = <number>_(4060).floor(-2);
// → 4000
result = <number>_.min([4, 2, 8, 6]);
result = <IStoogesAge>_.min(stoogesAges, function (stooge) { return stooge.age; });
result = <IStoogesAge>_.min(stoogesAges, 'age');
result = <_.LoDashWrapper<number>>_([4, 2, 8, 6]).min();
result = <_.LoDashWrapper<IStoogesAge>>_(stoogesAges).min(function (stooge) { return stooge.age; });
result = <_.LoDashWrapper<IStoogesAge>>_(stoogesAges).min('age');
// _.round
result = <number>_.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<number>;
let dictionary: _.Dictionary<number>;
let listIterator: (value: number, index: number, collection: _.List<number>) => number;
let dictionaryIterator: (value: number, key: string, collection: _.Dictionary<number>) => number;
let result: number;
result = _.min<number>(array);
result = _.min<number>(array, listIterator);
result = _.min<number>(array, listIterator, any);
result = _.min<number>(array, '');
result = _.min<{a: number}, number>(array, {a: 42});
result = _.min<number>(list);
result = _.min<number>(list, listIterator);
result = _.min<number>(list, listIterator, any);
result = _.min<number>(list, '');
result = _.min<{a: number}, number>(list, {a: 42});
result = _.min<number>(dictionary);
result = _.min<number>(dictionary, dictionaryIterator);
result = _.min<number>(dictionary, dictionaryIterator, any);
result = _.min<number>(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<number>();
result = _(list).min<number>(listIterator);
result = _(list).min<number>(listIterator, any);
result = _(list).min<number>('');
result = _(list).min<{a: number}, number>({a: 42});
result = _(dictionary).min<number>();
result = _(dictionary).min<number>(dictionaryIterator);
result = _(dictionary).min<number>(dictionaryIterator, any);
result = _(dictionary).min<number>('');
result = _(dictionary).min<{a: number}, number>({a: 42});
}
/**********
* Number *
**********/

215
lodash/lodash.d.ts vendored
View File

@ -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<T>(
collection: Array<T>,
callback?: ListIterator<T, any>,
thisArg?: any): T;
/**
* @see _.min
**/
min<T>(
collection: List<T>,
callback?: ListIterator<T, any>,
thisArg?: any): T;
/**
* @see _.min
**/
min<T>(
collection: Dictionary<T>,
callback?: ListIterator<T, any>,
thisArg?: any): T;
/**
* @see _.min
* @param pluckValue _.pluck style callback
**/
min<T>(
collection: Array<T>,
pluckValue: string): T;
/**
* @see _.min
* @param pluckValue _.pluck style callback
**/
min<T>(
collection: List<T>,
pluckValue: string): T;
/**
* @see _.min
* @param pluckValue _.pluck style callback
**/
min<T>(
collection: Dictionary<T>,
pluckValue: string): T;
/**
* @see _.min
* @param whereValue _.where style callback
**/
min<W, T>(
collection: Array<T>,
whereValue: W): T;
/**
* @see _.min
* @param whereValue _.where style callback
**/
min<W, T>(
collection: List<T>,
whereValue: W): T;
/**
* @see _.min
* @param whereValue _.where style callback
**/
min<W, T>(
collection: Dictionary<T>,
whereValue: W): T;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.min
**/
min(
callback?: ListIterator<T, any>,
thisArg?: any): LoDashWrapper<T>;
/**
* @see _.min
* @param pluckValue _.pluck style callback
**/
min(
pluckValue: string): LoDashWrapper<T>;
/**
* @see _.min
* @param whereValue _.where style callback
**/
min<W>(
whereValue: W): LoDashWrapper<T>;
}
//_.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 its 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<T>(
collection: List<T>,
iteratee?: ListIterator<T, any>,
thisArg?: any
): T;
/**
* @see _.min
*/
min<T>(
collection: Dictionary<T>,
iteratee?: DictionaryIterator<T, any>,
thisArg?: any
): T;
/**
* @see _.min
*/
min<T>(
collection: List<T>|Dictionary<T>,
iteratee?: string,
thisArg?: any
): T;
/**
* @see _.min
*/
min<TObject extends {}, T>(
collection: List<T>|Dictionary<T>,
whereValue?: TObject
): T;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.min
*/
min(
iteratee?: ListIterator<T, any>,
thisArg?: any
): T;
/**
* @see _.min
*/
min(
iteratee?: string,
thisArg?: any
): T;
/**
* @see _.min
*/
min<TObject extends {}>(
whereValue?: TObject
): T;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.min
*/
min<T>(
iteratee?: ListIterator<T, any>|DictionaryIterator<T, any>,
thisArg?: any
): T;
/**
* @see _.min
*/
min<T>(
iteratee?: string,
thisArg?: any
): T;
/**
* @see _.min
*/
min<TObject extends {}, T>(
whereValue?: TObject
): T;
}
/**********
* Number *
**********/