mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Make _.forEach and friends implicitly end a chain sequence.
This commit is contained in:
committed by
John-David Dalton
parent
1bfe25f1a5
commit
b5dd2e605d
@@ -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;
|
||||
|
||||
37
test/test.js
37
test/test.js
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user