diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index fdfc4603f..5790b6862 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -550,6 +550,10 @@ result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; }); +result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { + return num % 2 == 1; +}); + var mergeNames = { 'stooges': [ { 'name': 'moe' }, diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d382417c4..7d6eb3b8c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2235,6 +2235,34 @@ declare module _ { object: any, whereValue: Dictionary): string; + /** + * This method is like _.findKey except that it iterates over elements of a collection in the opposite order. + * @param object The object to search. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return The key of the found element, else undefined. + **/ + export function findLastKey( + object: any, + callback: (value: any) => boolean, + thisArg?: any): string; + + /** + * @see _.findLastKey + * @param pluckValue _.pluck style callback + **/ + export function findLastKey( + object: any, + pluckValue: string): string; + + /** + * @see _.findLastKey + * @param whereValue _.where style callback + **/ + export function findLastKey( + object: any, + whereValue: Dictionary): string; + /** * Recursively merges own enumerable properties of the source object(s), that don't resolve * to undefined into the destination object. Subsequent sources will overwrite property