mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +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.flattenDeep = flattenDeep;
|
||||||
lodash.flow = flow;
|
lodash.flow = flow;
|
||||||
lodash.flowRight = flowRight;
|
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.functions = functions;
|
||||||
lodash.groupBy = groupBy;
|
lodash.groupBy = groupBy;
|
||||||
lodash.indexBy = indexBy;
|
lodash.indexBy = indexBy;
|
||||||
@@ -12189,6 +12183,12 @@
|
|||||||
lodash.findWhere = findWhere;
|
lodash.findWhere = findWhere;
|
||||||
lodash.first = first;
|
lodash.first = first;
|
||||||
lodash.floor = floor;
|
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.get = get;
|
||||||
lodash.gt = gt;
|
lodash.gt = gt;
|
||||||
lodash.gte = gte;
|
lodash.gte = gte;
|
||||||
|
|||||||
37
test/test.js
37
test/test.js
@@ -4898,6 +4898,12 @@
|
|||||||
'findLast',
|
'findLast',
|
||||||
'findLastIndex',
|
'findLastIndex',
|
||||||
'findLastKey',
|
'findLastKey',
|
||||||
|
'forEach',
|
||||||
|
'forEachRight',
|
||||||
|
'forIn',
|
||||||
|
'forInRight',
|
||||||
|
'forOwn',
|
||||||
|
'forOwnRight',
|
||||||
'max',
|
'max',
|
||||||
'min',
|
'min',
|
||||||
'some'
|
'some'
|
||||||
@@ -5022,21 +5028,24 @@
|
|||||||
|
|
||||||
test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', 1, function() {
|
test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', 1, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var wrapped = _(array)[methodName](_.noop);
|
var actual = _(array)[methodName](_.noop);
|
||||||
ok(!(wrapped instanceof _));
|
ok(!(actual instanceof _));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest();
|
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) {
|
if (!isNpm) {
|
||||||
var wrapped = _(array).chain()[methodName](_.noop);
|
var wrapped = _(array).chain(),
|
||||||
ok(wrapped instanceof _);
|
actual = wrapped[methodName](_.noop);
|
||||||
|
|
||||||
|
ok(actual instanceof _);
|
||||||
|
notStrictEqual(actual, wrapped);
|
||||||
}
|
}
|
||||||
else {
|
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({
|
_.each({
|
||||||
'literal': 'abc',
|
'literal': 'abc',
|
||||||
'object': Object('abc')
|
'object': Object('abc')
|
||||||
@@ -5320,8 +5319,10 @@
|
|||||||
|
|
||||||
test('`_.' + methodName + '` should not return the existing wrapped value when chaining', 1, function() {
|
test('`_.' + methodName + '` should not return the existing wrapped value when chaining', 1, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var wrapped = _({ 'a': 1 });
|
var wrapped = _({ 'a': 1 }),
|
||||||
notStrictEqual(wrapped[methodName]({ 'b': 2 }), wrapped);
|
actual = wrapped[methodName]({ 'b': 2 });
|
||||||
|
|
||||||
|
notStrictEqual(actual, wrapped);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest();
|
skipTest();
|
||||||
|
|||||||
Reference in New Issue
Block a user