mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Simplify isArguments.
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import baseGetTag from './_baseGetTag.js';
|
||||
import isObjectLike from './isObjectLike.js';
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
const argsTag = '[object Arguments]';
|
||||
|
||||
/**
|
||||
* The base implementation of `isArguments`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||||
*/
|
||||
function baseIsArguments(value) {
|
||||
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
||||
}
|
||||
|
||||
export default baseIsArguments;
|
||||
@@ -1,14 +1,8 @@
|
||||
import baseIsArguments from './_baseIsArguments.js';
|
||||
import baseGetTag from './_baseGetTag.js';
|
||||
import isObjectLike from './isObjectLike.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
const objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
const hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Built-in value references. */
|
||||
const propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
/** `Object#toString` result references. */
|
||||
const argsTag = '[object Arguments]';
|
||||
|
||||
/**
|
||||
* Checks if `value` is likely an `arguments` object.
|
||||
@@ -27,7 +21,8 @@ const propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
* isArguments([1, 2, 3]);
|
||||
* // => false
|
||||
*/
|
||||
const isArguments = baseIsArguments(function(...args) { return args; }()) ? baseIsArguments : value => isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
||||
!propertyIsEnumerable.call(value, 'callee');
|
||||
function isArguments(value) {
|
||||
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
||||
}
|
||||
|
||||
export default isArguments;
|
||||
|
||||
Reference in New Issue
Block a user