added _.findKey definitions

This commit is contained in:
Brian Zengel
2013-10-20 12:12:26 -04:00
parent 52c7968b94
commit 9d58c2ea97
2 changed files with 33 additions and 0 deletions

View File

@@ -546,6 +546,10 @@ var result = <any>_.cloneDeep(stoogesAges, function(value) {
var foodDefaults = { 'name': 'apple' };
result = <any>_.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' });
result = <string>_.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) {
return num % 2 == 0;
});
var mergeNames = {
'stooges': [
{ 'name': 'moe' },

29
lodash/lodash.d.ts vendored
View File

@@ -2206,6 +2206,35 @@ declare module _ {
object: any,
...sources: any[]): any;
/**
* This method is like _.findIndex except that it returns the key of the first element that
* passes the callback check, instead of the element itself.
* @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 findKey(
object: any,
callback: (value: any) => boolean,
thisArg?: any): string;
/**
* @see _.findKey
* @param pluckValue _.pluck style callback
**/
export function findKey(
object: any,
pluckValue: string): string;
/**
* @see _.findKey
* @param whereValue _.where style callback
**/
export function findKey(
object: any,
whereValue: Dictionary<any>): 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