Add chainable definitions for _(...).forEach and aliases when passing an non-dictionary object.

This commit is contained in:
Brian Zengel
2014-06-03 13:24:46 -04:00
parent 1def2150e2
commit 79e22825d5
2 changed files with 18 additions and 0 deletions
+2
View File
@@ -397,9 +397,11 @@ result = <IFoodCombined>_.findLast(foodsCombined, 'organic');
result = <number[]>_.forEach([1, 2, 3], function (num) { console.log(num); });
result = <_.Dictionary<number>>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); });
result = <IFoodType>_.forEach<IFoodType, string>({ name: 'apple', type: 'fruit' }, function (value, key) { console.log(value, key) });
result = <number[]>_.each([1, 2, 3], function (num) { console.log(num); });
result = <_.Dictionary<number>>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); });
result = <IFoodType>_.each<IFoodType, string>({ name: 'apple', type: 'fruit' }, function (value, key) { console.log(value, key) });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).forEach(function (num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); });
+16
View File
@@ -2939,6 +2939,14 @@ declare module _ {
callback: ObjectIterator<T, void>,
thisArg?: any): Dictionary<T>;
/**
* @see _.each
**/
forEach<T extends {}, TValue>(
object: T,
callback: ObjectIterator<TValue, void>,
thisArg?: any): T
/**
* @see _.forEach
**/
@@ -2965,6 +2973,14 @@ declare module _ {
object: Dictionary<T>,
callback: ObjectIterator<T, void>,
thisArg?: any): Dictionary<T>;
/**
* @see _.each
**/
each<T extends {}, TValue>(
object: T,
callback: ObjectIterator<TValue, void>,
thisArg?: any): T
}
interface LoDashArrayWrapper<T> {