mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
_.at test fix + _.map/_.collect definitions
This commit is contained in:
+10
-2
@@ -202,8 +202,8 @@ result = <number[]>_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
* Collections *
|
||||
************* */
|
||||
|
||||
result = <string>_.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
|
||||
result = <string>_.at(['moe', 'larry', 'curly'], 0, 2);
|
||||
result = <string[]>_.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
|
||||
result = <string[]>_.at(['moe', 'larry', 'curly'], 0, 2);
|
||||
|
||||
result = <boolean>_.every([true, 1, null, 'yes'], Boolean);
|
||||
result = <boolean>_.every(stoogesAges, 'age');
|
||||
@@ -213,6 +213,14 @@ result = <boolean>_.every(stoogesAges, { 'age': 50 });
|
||||
result = <boolean>_.all(stoogesAges, 'age');
|
||||
result = <boolean>_.all(stoogesAges, { 'age': 50 });
|
||||
|
||||
result = <any[]>_.map([1, 2, 3], function(num) { return num * 3; });
|
||||
result = <any[]>_.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
|
||||
result = <any[]>_.map(stoogesAges, 'name');
|
||||
|
||||
result = <any[]>_.collect([1, 2, 3], function(num) { return num * 3; });
|
||||
result = <any[]>_.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
|
||||
result = <any[]>_.collect(stoogesAges, 'name');
|
||||
|
||||
result = <boolean>_.some([null, 0, 'yes', false], Boolean);
|
||||
result = <boolean>_.some(foodsCombined, 'organic');
|
||||
result = <boolean>_.some(foodsCombined, { 'type': 'meat' });
|
||||
|
||||
Vendored
+63
-42
@@ -846,6 +846,69 @@ declare module _ {
|
||||
collection: Collection<T>,
|
||||
whereValue: Dictionary<any>): boolean;
|
||||
|
||||
/**
|
||||
* Creates an array of values by running each element in the collection through the callback.
|
||||
* The callback is bound to thisArg and invoked with three arguments; (value, index|key,
|
||||
* 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 theArg The this binding of callback.
|
||||
* @return The mapped array result.
|
||||
**/
|
||||
export function map<T, TResult>(
|
||||
collection: List<T>,
|
||||
callback: ListIterator<T, TResult>,
|
||||
thisArg?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
* @param object The object to iterate over.
|
||||
* @param callback The function called per iteration.
|
||||
* @param thisArg `this` object in `iterator`, optional.
|
||||
* @return The mapped object result.
|
||||
**/
|
||||
export function map<T extends {}, TResult>(
|
||||
object: Dictionary<T>,
|
||||
callback: ObjectIterator<T, TResult>,
|
||||
thisArg?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
export function map<T, TResult>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
**/
|
||||
export function collect<T, TResult>(
|
||||
collection: List<T>,
|
||||
callback: ListIterator<T, TResult>,
|
||||
thisArg?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
**/
|
||||
export function collect<T extends {}, TResult>(
|
||||
object: Dictionary<T>,
|
||||
callback: ObjectIterator<T, TResult>,
|
||||
thisArg?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
**/
|
||||
export function collect<T, TResult>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): TResult[];
|
||||
|
||||
/**
|
||||
* Checks if the callback returns a truey value for any element of a collection. The function
|
||||
* returns as soon as it finds a passing value and does not iterate over the entire collection.
|
||||
@@ -969,48 +1032,6 @@ declare module _ {
|
||||
iterator: ObjectIterator<T, void >,
|
||||
context?: any): void;
|
||||
|
||||
/**
|
||||
* Produces a new array of values by mapping each value in list through a transformation function
|
||||
* (iterator). If the native map method exists, it will be used instead. If list is a JavaScript
|
||||
* object, iterator's arguments will be (value, key, object).
|
||||
* @param list Maps the elements of this array.
|
||||
* @param iterator Map iterator function for each element in `list`.
|
||||
* @param context `this` object in `iterator`, optional.
|
||||
* @return The mapped array result.
|
||||
**/
|
||||
export function map<T, TResult>(
|
||||
list: List<T>,
|
||||
iterator: ListIterator<T, TResult>,
|
||||
context?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
* @param object Maps the properties of this object.
|
||||
* @param iterator Map iterator function for each property on `obj`.
|
||||
* @param context `this` object in `iterator`, optional.
|
||||
* @return The mapped object result.
|
||||
**/
|
||||
export function map<T extends {}, TResult>(
|
||||
object: Dictionary<T>,
|
||||
iterator: ObjectIterator<T, TResult>,
|
||||
context?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
**/
|
||||
export function collect<T, TResult>(
|
||||
list: List<T>, iterator:
|
||||
ListIterator<T, TResult>,
|
||||
context?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
**/
|
||||
export function collect<T extends {}, TResult>(
|
||||
object: Dictionary<T>,
|
||||
iterator: ObjectIterator<T, TResult>,
|
||||
context?: any): TResult[];
|
||||
|
||||
/**
|
||||
* Also known as inject and foldl, reduce boils down a list of values into a single value.
|
||||
* Memo is the initial state of the reduction, and each successive step of it should be
|
||||
|
||||
Reference in New Issue
Block a user