From 763dc207ce508705aa46c16a599774971ca185ab Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Fri, 18 Oct 2013 18:51:05 -0400 Subject: [PATCH] _.forEachRight/_.eachRight definitions --- lodash/lodash-tests.ts | 6 ++++++ lodash/lodash.d.ts | 45 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d8878c290e..ca334a3d71 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -251,6 +251,12 @@ result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, fun result = _.each([1, 2, 3], function(num) { console.log(num); }); result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.forEachRight([1, 2, 3], function(num) { console.log(num); }); +result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + + result = _.eachRight([1, 2, 3], function(num) { console.log(num); }); + result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + result = _.map([1, 2, 3], function(num) { return num * 3; }); result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); result = _.map(stoogesAges, 'name'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 9e4853470d..30181a740b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1052,16 +1052,53 @@ declare module _ { /** * @see _.each - * @param object Iterators over this object's properties. - * @param iterator Iterator function for each property on `obj`. - * @param context 'this' object in `iterator`, optional. + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. **/ export function each( object: Dictionary, callback: ObjectIterator, thisArg?: any): Dictionary; - + /** + * This method is like _.forEach except that it iterates over elements of a + * collection from right to left. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + export function forEachRight( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.each + **/ + export function forEachRight( + object: Dictionary, + callback: ObjectIterator, + thisArg?: any): Dictionary; + + /** + * @see _.each + **/ + export function eachRight( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.each + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + export function eachRight( + object: Dictionary, + callback: ObjectIterator, + thisArg?: any): Dictionary; /** * Creates an array of values by running each element in the collection through the callback.