mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Add _.modArgsSet.
This commit is contained in:
44
lodash.js
44
lodash.js
@@ -7600,16 +7600,51 @@
|
||||
* return [x, y];
|
||||
* }, square, doubled);
|
||||
*
|
||||
* modded(3, 4);
|
||||
* // => [9, 8]
|
||||
* modded(9, 3);
|
||||
* // => [81, 6]
|
||||
*
|
||||
* modded(5, 10);
|
||||
* // => [25, 20]
|
||||
* modded(10, 5);
|
||||
* // => [100, 10]
|
||||
*/
|
||||
var modArgs = createModArgs(function(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
|
||||
* `func` predicate is invoked with the `this` binding and arguments of the
|
||||
@@ -11833,6 +11868,7 @@
|
||||
lodash.methodOf = methodOf;
|
||||
lodash.mixin = mixin;
|
||||
lodash.modArgs = modArgs;
|
||||
lodash.modArgsSet = modArgsSet;
|
||||
lodash.negate = negate;
|
||||
lodash.omit = omit;
|
||||
lodash.omitBy = omitBy;
|
||||
|
||||
@@ -17638,6 +17638,7 @@
|
||||
'delay',
|
||||
'memoize',
|
||||
'modArgs',
|
||||
'modArgsSet',
|
||||
'negate',
|
||||
'once',
|
||||
'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) {
|
||||
var expected = _.map(falsey, _.constant(true)),
|
||||
func = _[methodName];
|
||||
|
||||
Reference in New Issue
Block a user