Make _.isArray consistent with the other isType methods.

Former-commit-id: adcf242ba7692c96fb8f570118acd7fd0a4602da
This commit is contained in:
John-David Dalton
2013-04-15 23:49:17 -07:00
parent bda869ea54
commit b1f8e845df
9 changed files with 316 additions and 294 deletions

View File

@@ -483,28 +483,6 @@
};
}
/**
* Checks if `value` is an array.
*
* @static
* @memberOf _
* @category Objects
* @param {Mixed} value The value to check.
* @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
* @example
*
* (function() { return _.isArray(arguments); })();
* // => false
*
* _.isArray([1, 2, 3]);
* // => true
*/
var isArray = nativeIsArray || function(value) {
// `instanceof` may cause a memory leak in IE 7 if `value` is a host object
// http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
return (support.argsObject && value instanceof Array) || toString.call(value) == arrayClass;
};
/**
* A fallback implementation of `Object.keys` which produces an array of the
* given object's own enumerable property names.
@@ -842,6 +820,26 @@
return result;
}
/**
* Checks if `value` is an array.
*
* @static
* @memberOf _
* @category Objects
* @param {Mixed} value The value to check.
* @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
* @example
*
* (function() { return _.isArray(arguments); })();
* // => false
*
* _.isArray([1, 2, 3]);
* // => true
*/
var isArray = nativeIsArray || function(value) {
return toString.call(value) == arrayClass;
};
/**
* Checks if `value` is a boolean value.
*
@@ -873,7 +871,7 @@
* // => true
*/
function isDate(value) {
return value instanceof Date || toString.call(value) == dateClass;
return toString.call(value) == dateClass;
}
/**
@@ -1118,7 +1116,7 @@
// fallback for older versions of Chrome and Safari
if (isFunction(/x/)) {
isFunction = function(value) {
return value instanceof Function || toString.call(value) == funcClass;
return toString.call(value) == funcClass;
};
}
@@ -1232,7 +1230,7 @@
* // => true
*/
function isRegExp(value) {
return value instanceof RegExp || toString.call(value) == regexpClass;
return toString.call(value) == regexpClass;
}
/**