mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
started passing in the collection as the third argument to _.each iterators (Issue #1)
This commit is contained in:
@@ -38,16 +38,16 @@
|
||||
if (obj.forEach) {
|
||||
obj.forEach(iterator, context);
|
||||
} else if (obj.length) {
|
||||
for (var i=0, l = obj.length; i<l; i++) iterator.call(context, obj[i], i);
|
||||
for (var i=0, l = obj.length; i<l; i++) iterator.call(context, obj[i], i, obj);
|
||||
} else if (obj.each) {
|
||||
obj.each(function(value) { iterator.call(context, value, index++); });
|
||||
obj.each(function(value) { iterator.call(context, value, index++, obj); });
|
||||
} else {
|
||||
var i = 0;
|
||||
for (var key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var value = obj[key], pair = [key, value];
|
||||
pair.key = key;
|
||||
pair.value = value;
|
||||
iterator.call(context, pair, i++);
|
||||
iterator.call(context, pair, i++, obj);
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
Reference in New Issue
Block a user