_.min definitions

This commit is contained in:
Brian Zengel
2013-10-18 20:26:50 -04:00
parent e7245ae3f8
commit 26e5bfd50c
2 changed files with 41 additions and 20 deletions
+4
View File
@@ -304,6 +304,10 @@ result = <number>_.max([4, 2, 8, 6]);
result = <IStoogesAge>_.max(stoogesAges, function(stooge) { return stooge.age; });
result = <IStoogesAge>_.max(stooges, 'age');
result = <number>_.min([4, 2, 8, 6]);
result = <IStoogesAge>_.min(stoogesAges, function(stooge) { return stooge.age; });
result = <IStoogesAge>_.min(stooges, 'age');
result = <any>_.reduce([1, 2, 3], function(sum, num) {
return sum + num;
});
+37 -20
View File
@@ -1379,6 +1379,43 @@ declare module _ {
collection: Collection<T>,
whereValue: Dictionary<any>): T;
/**
* 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.
**/
export function min<T>(
collection: Collection<T>,
callback?: ListIterator<T, any>,
thisArg?: any): T;
/**
* @see _.min
* @param pluckValue _.pluck style callback
**/
export function min<T>(
collection: Collection<T>,
pluckValue: string): T;
/**
* @see _.min
* @param whereValue _.where style callback
**/
export function min<T>(
collection: Collection<T>,
whereValue: Dictionary<any>): T;
/**
* Reduces a collection to a value which is the accumulated result of running each
* element in the collection through the callback, where each successive callback execution
@@ -1571,26 +1608,6 @@ declare module _ {
/**
* Returns the minimum value in list.
* @param list Finds the minimum value in this list.
* @return Minimum value in `list`.
**/
export function min(list: List<number>): number;
/**
* Returns the minimum value in list. If iterator is passed, it will be used on each value to generate
* the criterion by which the value is ranked.
* @param list Finds the minimum value in this list.
* @param iterator Compares each element in `list` to find the minimum value.
* @param context `this` object in `iterator`, optional.
* @return The minimum element within `list`.
**/
export function min<T>(
list: Collection<T>,
iterator?: ListIterator<T, any>,
context?: any): T;
/**
* Returns a sorted copy of list, ranked in ascending order by the results of running each value
* through iterator. Iterator may also be the string name of the property to sort by (eg. length).