mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Optimize _.isArray fallback, baseFlatten, & _.isArguments for plain objects.
This commit is contained in:
10
dist/lodash.js
vendored
10
dist/lodash.js
vendored
@@ -843,8 +843,8 @@
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
|
||||
// recursively flatten arrays (susceptible to call stack limits)
|
||||
if (value && typeof value == 'object' && (isArray(value) || isArguments(value))) {
|
||||
if (value && typeof value == 'object' && value.length && (isArray(value) || isArguments(value))) {
|
||||
// recursively flatten arrays (susceptible to call stack limits)
|
||||
if (!isShallow) {
|
||||
value = baseFlatten(value, isShallow, isArgArrays);
|
||||
}
|
||||
@@ -1401,7 +1401,8 @@
|
||||
* // => false
|
||||
*/
|
||||
function isArguments(value) {
|
||||
return (value && typeof value == 'object') ? toString.call(value) == argsClass : false;
|
||||
return value && typeof value == 'object' && typeof value.length == 'number' &&
|
||||
toString.call(value) == argsClass || false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1422,7 +1423,8 @@
|
||||
* // => true
|
||||
*/
|
||||
var isArray = nativeIsArray || function(value) {
|
||||
return (value && typeof value == 'object') ? toString.call(value) == arrayClass : false;
|
||||
return value && typeof value == 'object' && typeof value.length == 'number' &&
|
||||
toString.call(value) == arrayClass || false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user