Allow over, overEvery, and overSome to accept matchesProperty shorthands. [closes #2193]

This commit is contained in:
John-David Dalton
2016-04-01 09:00:32 -07:00
parent b8096df6d8
commit b257bb9c9e
3 changed files with 11 additions and 27 deletions

View File

@@ -164,6 +164,10 @@ exports.methodRearg = {
exports.methodSpread = { exports.methodSpread = {
'invokeArgs': 2, 'invokeArgs': 2,
'invokeArgsMap': 2, 'invokeArgsMap': 2,
'over': 0,
'overArgs': 1,
'overEvery': 0,
'overSome': 0,
'partial': 1, 'partial': 1,
'partialRight': 1, 'partialRight': 1,
'without': 1 'without': 1
@@ -263,6 +267,7 @@ exports.skipRearg = {
'matchesProperty': true, 'matchesProperty': true,
'merge': true, 'merge': true,
'multiply': true, 'multiply': true,
'overArgs': true,
'partial': true, 'partial': true,
'partialRight': true, 'partialRight': true,
'random': true, 'random': true,

View File

@@ -4607,7 +4607,7 @@
*/ */
function createOver(arrayFunc) { function createOver(arrayFunc) {
return rest(function(iteratees) { return rest(function(iteratees) {
iteratees = arrayMap(baseFlatten(iteratees, 1), getIteratee()); iteratees = arrayMap(iteratees, getIteratee());
return rest(function(args) { return rest(function(args) {
var thisArg = this; var thisArg = this;
return arrayFunc(iteratees, function(iteratee) { return arrayFunc(iteratees, function(iteratee) {
@@ -9548,7 +9548,7 @@
* @memberOf _ * @memberOf _
* @category Function * @category Function
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {...(Function|Function[])} [transforms] The functions to transform * @param {...Function} [transforms] The functions to transform
* arguments, specified individually or in arrays. * arguments, specified individually or in arrays.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
* @example * @example
@@ -9572,7 +9572,7 @@
* // => [100, 10] * // => [100, 10]
*/ */
var overArgs = rest(function(func, transforms) { var overArgs = rest(function(func, transforms) {
transforms = arrayMap(baseFlatten(transforms, 1), getIteratee()); transforms = arrayMap(transforms, getIteratee());
var funcsLength = transforms.length; var funcsLength = transforms.length;
return rest(function(args) { return rest(function(args) {
@@ -14644,7 +14644,7 @@
* @memberOf _ * @memberOf _
* @since 4.0.0 * @since 4.0.0
* @category Util * @category Util
* @param {...(Function|Function[])} iteratees The iteratees to invoke. * @param {...Function} iteratees The iteratees to invoke.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
* @example * @example
* *
@@ -14663,7 +14663,7 @@
* @memberOf _ * @memberOf _
* @since 4.0.0 * @since 4.0.0
* @category Util * @category Util
* @param {...(Function|Function[])} predicates The predicates to check. * @param {...Function} predicates The predicates to check.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
* @example * @example
* *
@@ -14688,7 +14688,7 @@
* @memberOf _ * @memberOf _
* @since 4.0.0 * @since 4.0.0
* @category Util * @category Util
* @param {...(Function|Function[])} predicates The predicates to check. * @param {...Function} predicates The predicates to check.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
* @example * @example
* *

View File

@@ -15564,13 +15564,6 @@
assert.deepEqual(over(5, 10), [10, 100]); assert.deepEqual(over(5, 10), [10, 100]);
}); });
QUnit.test('should flatten `transforms`', function(assert) {
assert.expect(1);
var over = _.overArgs(fn, [doubled, square], String);
assert.deepEqual(over(5, 10, 15), [10, 100, '15']);
});
QUnit.test('should not transform any argument greater than the number of transforms', function(assert) { QUnit.test('should not transform any argument greater than the number of transforms', function(assert) {
assert.expect(1); assert.expect(1);
@@ -16097,13 +16090,6 @@
assert.strictEqual(over(object), false); assert.strictEqual(over(object), false);
}); });
QUnit.test('should flatten `predicates`', function(assert) {
assert.expect(1);
var over = _.overEvery(alwaysTrue, [alwaysFalse]);
assert.strictEqual(over(), false);
});
QUnit.test('should provide arguments to predicates', function(assert) { QUnit.test('should provide arguments to predicates', function(assert) {
assert.expect(1); assert.expect(1);
@@ -16199,13 +16185,6 @@
assert.strictEqual(over(object), false); assert.strictEqual(over(object), false);
}); });
QUnit.test('should flatten `predicates`', function(assert) {
assert.expect(1);
var over = _.overSome(alwaysFalse, [alwaysTrue]);
assert.strictEqual(over(), true);
});
QUnit.test('should provide arguments to predicates', function(assert) { QUnit.test('should provide arguments to predicates', function(assert) {
assert.expect(1); assert.expect(1);