From 45f668b4169f18cb76483d25a769d70917a84e70 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 4 Oct 2016 22:26:21 -0700 Subject: [PATCH] Add `baseIsArguments`. --- lodash.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lodash.js b/lodash.js index 67bacaca5..cea37e2af 100644 --- a/lodash.js +++ b/lodash.js @@ -1473,6 +1473,7 @@ getPrototype = overArg(Object.getPrototypeOf, Object), iteratorSymbol = Symbol ? Symbol.iterator : undefined, objectCreate = Object.create, + propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined; @@ -3203,6 +3204,17 @@ return func == null ? undefined : apply(func, object, args); } + /** + * 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) && objectToString.call(value) == argsTag; + } + /** * The base implementation of `_.isArrayBuffer` without Node.js optimizations. * @@ -11186,9 +11198,10 @@ * _.isArguments([1, 2, 3]); * // => false */ - function isArguments(value) { - return isObjectLike(value) && objectToString.call(value) == argsTag; - } + var isArguments = baseIsArguments(arguments) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); + }; /** * Checks if `value` is classified as an `Array` object.