mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Remove duplicate isArguments method and movenegate to the "Functions" category.
This commit is contained in:
85
dist/lodash.underscore.js
vendored
85
dist/lodash.underscore.js
vendored
@@ -1083,34 +1083,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Checks if `value` is an `arguments` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if the `value` is an `arguments` object, else `false`.
|
||||
* @example
|
||||
*
|
||||
* (function() { return _.isArguments(arguments); })(1, 2, 3);
|
||||
* // => true
|
||||
*
|
||||
* _.isArguments([1, 2, 3]);
|
||||
* // => false
|
||||
*/
|
||||
function isArguments(value) {
|
||||
return value && typeof value == 'object' && typeof value.length == 'number' &&
|
||||
toString.call(value) == argsClass || false;
|
||||
}
|
||||
// fallback for environments that can't detect `arguments` objects by [[Class]]
|
||||
if (!isArguments(arguments)) {
|
||||
isArguments = function(value) {
|
||||
return value && typeof value == 'object' && typeof value.length == 'number' &&
|
||||
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee') || false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A fallback implementation of `Object.keys` which creates an array of the
|
||||
* own enumerable property names of `object`.
|
||||
@@ -1370,6 +1342,7 @@
|
||||
args.push(value);
|
||||
}
|
||||
}
|
||||
argsLength = args.length
|
||||
var array = args[0],
|
||||
index = -1,
|
||||
indexOf = getIndexOf(),
|
||||
@@ -3436,6 +3409,33 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that negates the result of `func`. The `func` function
|
||||
* is executed with the `this` binding and arguments of the created function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Functions
|
||||
* @param {Function} func The function to negate.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* function isEven(num) {
|
||||
* return num % 2 == 0;
|
||||
* }
|
||||
*
|
||||
* _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
|
||||
* // => [1, 3, 5]
|
||||
*/
|
||||
function negate(func) {
|
||||
if (!isFunction(func)) {
|
||||
throw new TypeError;
|
||||
}
|
||||
return function() {
|
||||
return !func.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that is restricted to execute `func` once. Repeat calls to
|
||||
* the function will return the value of the first call. The `func` is executed
|
||||
@@ -3822,7 +3822,7 @@
|
||||
toString.call(value) == argsClass || false;
|
||||
}
|
||||
// fallback for environments that can't detect `arguments` objects by [[Class]]
|
||||
if (!support.argsClass) {
|
||||
if (!isArguments(arguments)) {
|
||||
isArguments = function(value) {
|
||||
return value && typeof value == 'object' && typeof value.length == 'number' &&
|
||||
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee') || false;
|
||||
@@ -4774,33 +4774,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that negates the result of `func`. The `func` function
|
||||
* is executed with the `this` binding and arguments of the created function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utilities
|
||||
* @param {Function} func The function to negate.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* function isEven(num) {
|
||||
* return num % 2 == 0;
|
||||
* }
|
||||
*
|
||||
* _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
|
||||
* // => [1, 3, 5]
|
||||
*/
|
||||
function negate(func) {
|
||||
if (!isFunction(func)) {
|
||||
throw new TypeError;
|
||||
}
|
||||
return function() {
|
||||
return !func.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverts the '_' variable to its previous value and returns a reference to
|
||||
* the `lodash` function.
|
||||
|
||||
Reference in New Issue
Block a user