added _.forIn definition

This commit is contained in:
Brian Zengel
2013-10-20 12:27:07 -04:00
parent fca7df70bc
commit 47dfdd98a2
2 changed files with 27 additions and 0 deletions
+12
View File
@@ -554,6 +554,18 @@ result = <string>_.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);
});
var mergeNames = {
'stooges': [
{ 'name': 'moe' },
+15
View File
@@ -2263,6 +2263,21 @@ declare module _ {
object: any,
whereValue: Dictionary<any>): string;
/**
* Iterates over own and inherited enumerable properties of an object, executing the callback for
* each property. The callback is bound to thisArg and invoked with three arguments; (value, key,
* object). Callbacks may exit iteration early by explicitly returning false.
* @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 forIn<T extends {}>(
object: Dictionary<T>,
callback?: ObjectIterator<T, void>,
thisArg?: any): Dictionary<T>;
/**
* 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