mirror of
https://github.com/tenrok/axios.git
synced 2026-06-08 17:22:34 +03:00
Fixing isArrayLike to allow length as a param. Added test
This commit is contained in:
+11
-1
@@ -130,6 +130,16 @@ function trim(str) {
|
||||
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an Arguments object
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an Arguments object, otherwise false
|
||||
*/
|
||||
function isArguments(val) {
|
||||
return toString.call(val) === '[object Arguments]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over an Array or an Object invoking a function for each item.
|
||||
*
|
||||
@@ -149,7 +159,7 @@ function forEach(obj, fn) {
|
||||
}
|
||||
|
||||
// Check if obj is array-like
|
||||
var isArrayLike = isArray(obj) || (typeof obj === 'object' && !isNaN(obj.length));
|
||||
var isArrayLike = isArray(obj) || isArguments(obj);
|
||||
|
||||
// Force an array if not already something iterable
|
||||
if (typeof obj !== 'object' && !isArrayLike) {
|
||||
|
||||
Reference in New Issue
Block a user