Make _.forEach and friends implicitly end a chain sequence.

This commit is contained in:
jdalton
2015-07-03 10:24:23 -07:00
committed by John-David Dalton
parent 1bfe25f1a5
commit b5dd2e605d
2 changed files with 25 additions and 24 deletions

View File

@@ -12080,12 +12080,6 @@
lodash.flattenDeep = flattenDeep;
lodash.flow = flow;
lodash.flowRight = flowRight;
lodash.forEach = forEach;
lodash.forEachRight = forEachRight;
lodash.forIn = forIn;
lodash.forInRight = forInRight;
lodash.forOwn = forOwn;
lodash.forOwnRight = forOwnRight;
lodash.functions = functions;
lodash.groupBy = groupBy;
lodash.indexBy = indexBy;
@@ -12189,6 +12183,12 @@
lodash.findWhere = findWhere;
lodash.first = first;
lodash.floor = floor;
lodash.forEach = forEach;
lodash.forEachRight = forEachRight;
lodash.forIn = forIn;
lodash.forInRight = forInRight;
lodash.forOwn = forOwn;
lodash.forOwnRight = forOwnRight;
lodash.get = get;
lodash.gt = gt;
lodash.gte = gte;

View File

@@ -4898,6 +4898,12 @@
'findLast',
'findLastIndex',
'findLastKey',
'forEach',
'forEachRight',
'forIn',
'forInRight',
'forOwn',
'forOwnRight',
'max',
'min',
'some'
@@ -5022,21 +5028,24 @@
test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', 1, function() {
if (!isNpm) {
var wrapped = _(array)[methodName](_.noop);
ok(!(wrapped instanceof _));
var actual = _(array)[methodName](_.noop);
ok(!(actual instanceof _));
}
else {
skipTest();
}
});
test('`_.' + methodName + '` should return a wrapped value when implicitly chaining', 1, function() {
test('`_.' + methodName + '` should return a wrapped value when explicitly chaining', 2, function() {
if (!isNpm) {
var wrapped = _(array).chain()[methodName](_.noop);
ok(wrapped instanceof _);
var wrapped = _(array).chain(),
actual = wrapped[methodName](_.noop);
ok(actual instanceof _);
notStrictEqual(actual, wrapped);
}
else {
skipTest();
skipTest(2);
}
});
});
@@ -5076,16 +5085,6 @@
}
});
test('`_.' + methodName + '` should not return the existing wrapped value when chaining', 1, function() {
if (!(isBaseEach || isNpm)) {
var wrapped = _(array);
notStrictEqual(wrapped[methodName](_.noop), wrapped);
}
else {
skipTest();
}
});
_.each({
'literal': 'abc',
'object': Object('abc')
@@ -5320,8 +5319,10 @@
test('`_.' + methodName + '` should not return the existing wrapped value when chaining', 1, function() {
if (!isNpm) {
var wrapped = _({ 'a': 1 });
notStrictEqual(wrapped[methodName]({ 'b': 2 }), wrapped);
var wrapped = _({ 'a': 1 }),
actual = wrapped[methodName]({ 'b': 2 });
notStrictEqual(actual, wrapped);
}
else {
skipTest();