1 |
3a515b92
|
cagy
|
'use strict';
|
2 |
|
|
|
3 |
|
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
4 |
|
|
var toStr = Object.prototype.toString;
|
5 |
|
|
|
6 |
|
|
var isStandardArguments = function isArguments(value) {
|
7 |
|
|
if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
|
8 |
|
|
return false;
|
9 |
|
|
}
|
10 |
|
|
return toStr.call(value) === '[object Arguments]';
|
11 |
|
|
};
|
12 |
|
|
|
13 |
|
|
var isLegacyArguments = function isArguments(value) {
|
14 |
|
|
if (isStandardArguments(value)) {
|
15 |
|
|
return true;
|
16 |
|
|
}
|
17 |
|
|
return value !== null &&
|
18 |
|
|
typeof value === 'object' &&
|
19 |
|
|
typeof value.length === 'number' &&
|
20 |
|
|
value.length >= 0 &&
|
21 |
|
|
toStr.call(value) !== '[object Array]' &&
|
22 |
|
|
toStr.call(value.callee) === '[object Function]';
|
23 |
|
|
};
|
24 |
|
|
|
25 |
|
|
var supportsStandardArguments = (function () {
|
26 |
|
|
return isStandardArguments(arguments);
|
27 |
|
|
}());
|
28 |
|
|
|
29 |
|
|
isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
|
30 |
|
|
|
31 |
|
|
module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
|