Remove chainability from _.forEach in the lodash underscore build.

Former-commit-id: 1db7daafacddcf78492643d6c6301af706b92150
This commit is contained in:
John-David Dalton
2012-10-24 19:49:26 -07:00
parent 7457001275
commit 447e43e8f4
3 changed files with 17 additions and 10 deletions

View File

@@ -632,21 +632,23 @@
vm.runInContext(source, context);
var lodash = context._;
lodash.each(array, function(value) {
last = value;
return false;
});
var object = { 'fn': lodash.bind(function(x) { return this.x + x; }, { 'x': 1 }, 1) };
var object = { 'fn': lodash.bind(function(foo) { return foo + this.bar; }, { 'bar': 1 }, 1) };
equal(object.fn(), 2, '_.bind: ' + basename);
ok(lodash.clone(array, true)[0] === array[0], '_.clone: ' + basename);
equal(last.value, 2, '_.each: ' + basename);
ok(lodash.clone(array, true)[0] === array[0], '_.clone should be shallow: ' + basename);
equal(lodash.every([true, false, true]), false, '_.every: ' + basename);
object = { 'length': 0, 'splice': Array.prototype.splice };
equal(lodash.isEmpty(object), false, '_.isEmpty: ' + basename);
var actual = lodash.forEach(array, function(value) {
last = value;
return false;
});
equal(last.value, 2, '_.forEach should not exit early: ' + basename);
equal(actual, undefined, '_.forEach should return undefined: ' + basename);
// avoid issues comparing objects with `deepEqual`
object = { 'a': 1, 'b': 2, 'c': 3 };
var actual = lodash.omit(object, function(value) { return value == 3; });