mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Use the argument predicate instead of func for _.negate.
This commit is contained in:
13
lodash.js
13
lodash.js
@@ -5220,13 +5220,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that negates the result of `func`. The `func` function
|
* Creates a function that negates the result of the predicate `func`. The
|
||||||
* is executed with the `this` binding and arguments of the created function.
|
* `func` function is executed with the `this` binding and arguments of the
|
||||||
|
* created function.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Functions
|
* @category Functions
|
||||||
* @param {Function} func The function to negate.
|
* @param {Function} predicate The predicate to negate.
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -5237,12 +5238,12 @@
|
|||||||
* _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
|
* _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
|
||||||
* // => [1, 3, 5]
|
* // => [1, 3, 5]
|
||||||
*/
|
*/
|
||||||
function negate(func) {
|
function negate(predicate) {
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(predicate)) {
|
||||||
throw new TypeError;
|
throw new TypeError;
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
return !func.apply(this, arguments);
|
return !predicate.apply(this, arguments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user