mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +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';
|
import isObjectLike from './isObjectLike.js';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** `Object#toString` result references. */
|
||||||
const objectProto = Object.prototype;
|
const argsTag = '[object Arguments]';
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
|
||||||
const hasOwnProperty = objectProto.hasOwnProperty;
|
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
const propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is likely an `arguments` object.
|
* Checks if `value` is likely an `arguments` object.
|
||||||
@@ -27,7 +21,8 @@ const propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|||||||
* isArguments([1, 2, 3]);
|
* isArguments([1, 2, 3]);
|
||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
const isArguments = baseIsArguments(function(...args) { return args; }()) ? baseIsArguments : value => isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
function isArguments(value) {
|
||||||
!propertyIsEnumerable.call(value, 'callee');
|
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
||||||
|
}
|
||||||
|
|
||||||
export default isArguments;
|
export default isArguments;
|
||||||
|
|||||||
Reference in New Issue
Block a user