From 04086de40603b7ac1c11d0cfbf47f55b50cf1a29 Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Sun, 20 Oct 2013 12:29:20 -0400 Subject: [PATCH] added _.forInRight definition --- lodash/lodash-tests.ts | 20 ++++++++++++-------- lodash/lodash.d.ts | 13 +++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index e8c44b6f1..1dc20268b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -72,6 +72,14 @@ var keys: IKey[] = [ { 'dir': 'right', 'code': 100 } ]; +function Dog(name) { + this.name = name; +} + +Dog.prototype.bark = function() { + console.log('Woof, woof!'); +}; + var result; //Array Method Tests @@ -554,18 +562,14 @@ result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) return num % 2 == 1; }); -function Dog(name) { - this.name = name; -} - -Dog.prototype.bark = function() { - console.log('Woof, woof!'); -}; - _.forIn(new Dog('Dagny'), function(value, key) { console.log(key); }); +_.forInRight(new Dog('Dagny'), function(value, key) { + console.log(key); +}); + var mergeNames = { 'stooges': [ { 'name': 'moe' }, diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 6c4d45e2a..d4d1b47c3 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2277,6 +2277,19 @@ declare module _ { callback?: ObjectIterator, thisArg?: any): Dictionary; + /** + * This method is like _.forIn except that it iterates over elements of a collection in the + * opposite order. + * @param object The object to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return object + **/ + export function forInRight( + object: Dictionary, + callback?: ObjectIterator, + thisArg?: any): Dictionary; + /** * Recursively merges own enumerable properties of the source object(s), that don't resolve