mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Add _.modArgsSet.
This commit is contained in:
44
lodash.js
44
lodash.js
@@ -7600,16 +7600,51 @@
|
|||||||
* return [x, y];
|
* return [x, y];
|
||||||
* }, square, doubled);
|
* }, square, doubled);
|
||||||
*
|
*
|
||||||
* modded(3, 4);
|
* modded(9, 3);
|
||||||
* // => [9, 8]
|
* // => [81, 6]
|
||||||
*
|
*
|
||||||
* modded(5, 10);
|
* modded(10, 5);
|
||||||
* // => [25, 20]
|
* // => [100, 10]
|
||||||
*/
|
*/
|
||||||
var modArgs = createModArgs(function(value) {
|
var modArgs = createModArgs(function(value) {
|
||||||
return [value];
|
return [value];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is like `_.modArgs` except that each transform function is
|
||||||
|
* provided all arguments the created function is invoked with.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @category Function
|
||||||
|
* @param {Function} func The function to wrap.
|
||||||
|
* @param {...(Function|Function[])} [transforms] The functions to transform
|
||||||
|
* arguments, specified individually or in arrays.
|
||||||
|
* @returns {Function} Returns the new function.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* function multiply(x, y) {
|
||||||
|
* return x * y;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* function divide(x, y) {
|
||||||
|
* return x / y;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* var modded = _.modArgsSet(function(x, y) {
|
||||||
|
* return [x, y];
|
||||||
|
* }, multiply, divide);
|
||||||
|
*
|
||||||
|
* modded(9, 3);
|
||||||
|
* // => [27, 3]
|
||||||
|
*
|
||||||
|
* modded(10, 5);
|
||||||
|
* // => [50, 2]
|
||||||
|
*/
|
||||||
|
var modArgsSet = createModArgs(function(value, index, args) {
|
||||||
|
return args;
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that negates the result of the predicate `func`. The
|
* Creates a function that negates the result of the predicate `func`. The
|
||||||
* `func` predicate is invoked with the `this` binding and arguments of the
|
* `func` predicate is invoked with the `this` binding and arguments of the
|
||||||
@@ -11833,6 +11868,7 @@
|
|||||||
lodash.methodOf = methodOf;
|
lodash.methodOf = methodOf;
|
||||||
lodash.mixin = mixin;
|
lodash.mixin = mixin;
|
||||||
lodash.modArgs = modArgs;
|
lodash.modArgs = modArgs;
|
||||||
|
lodash.modArgsSet = modArgsSet;
|
||||||
lodash.negate = negate;
|
lodash.negate = negate;
|
||||||
lodash.omit = omit;
|
lodash.omit = omit;
|
||||||
lodash.omitBy = omitBy;
|
lodash.omitBy = omitBy;
|
||||||
|
|||||||
@@ -17638,6 +17638,7 @@
|
|||||||
'delay',
|
'delay',
|
||||||
'memoize',
|
'memoize',
|
||||||
'modArgs',
|
'modArgs',
|
||||||
|
'modArgsSet',
|
||||||
'negate',
|
'negate',
|
||||||
'once',
|
'once',
|
||||||
'partial',
|
'partial',
|
||||||
@@ -17753,7 +17754,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should throw an error for falsey arguments', 23, function() {
|
test('should throw an error for falsey arguments', 24, function() {
|
||||||
_.each(rejectFalsey, function(methodName) {
|
_.each(rejectFalsey, function(methodName) {
|
||||||
var expected = _.map(falsey, _.constant(true)),
|
var expected = _.map(falsey, _.constant(true)),
|
||||||
func = _[methodName];
|
func = _[methodName];
|
||||||
|
|||||||
Reference in New Issue
Block a user