Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81145 views
1
/**
2
* lodash 3.0.3 (Custom Build) <https://lodash.com/>
3
* Build: `lodash modern modularize exports="npm" -o ./`
4
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
5
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
6
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
7
* Available under MIT license <https://lodash.com/license>
8
*/
9
10
/** `Object#toString` result references. */
11
var argsTag = '[object Arguments]';
12
13
/**
14
* Checks if `value` is object-like.
15
*
16
* @private
17
* @param {*} value The value to check.
18
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
19
*/
20
function isObjectLike(value) {
21
return !!value && typeof value == 'object';
22
}
23
24
/** Used for native method references. */
25
var objectProto = Object.prototype;
26
27
/**
28
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
29
* of values.
30
*/
31
var objToString = objectProto.toString;
32
33
/**
34
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
35
* of an array-like value.
36
*/
37
var MAX_SAFE_INTEGER = 9007199254740991;
38
39
/**
40
* The base implementation of `_.property` without support for deep paths.
41
*
42
* @private
43
* @param {string} key The key of the property to get.
44
* @returns {Function} Returns the new function.
45
*/
46
function baseProperty(key) {
47
return function(object) {
48
return object == null ? undefined : object[key];
49
};
50
}
51
52
/**
53
* Gets the "length" property value of `object`.
54
*
55
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
56
* that affects Safari on at least iOS 8.1-8.3 ARM64.
57
*
58
* @private
59
* @param {Object} object The object to query.
60
* @returns {*} Returns the "length" value.
61
*/
62
var getLength = baseProperty('length');
63
64
/**
65
* Checks if `value` is array-like.
66
*
67
* @private
68
* @param {*} value The value to check.
69
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
70
*/
71
function isArrayLike(value) {
72
return value != null && isLength(getLength(value));
73
}
74
75
/**
76
* Checks if `value` is a valid array-like length.
77
*
78
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
79
*
80
* @private
81
* @param {*} value The value to check.
82
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
83
*/
84
function isLength(value) {
85
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
86
}
87
88
/**
89
* Checks if `value` is classified as an `arguments` object.
90
*
91
* @static
92
* @memberOf _
93
* @category Lang
94
* @param {*} value The value to check.
95
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
96
* @example
97
*
98
* _.isArguments(function() { return arguments; }());
99
* // => true
100
*
101
* _.isArguments([1, 2, 3]);
102
* // => false
103
*/
104
function isArguments(value) {
105
return isObjectLike(value) && isArrayLike(value) && objToString.call(value) == argsTag;
106
}
107
108
module.exports = isArguments;
109
110