mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Optimize _.isArray fallback, _.isDate, _.isFunction, and _.isRegExp.
Former-commit-id: a3e350bf1fa91a9582ba6a0effe61d4589cc8afe
This commit is contained in:
@@ -908,7 +908,7 @@
|
||||
* // => true
|
||||
*/
|
||||
var isArray = nativeIsArray || function(value) {
|
||||
return toString.call(value) == arrayClass;
|
||||
return value instanceof Array || toString.call(value) == arrayClass;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -942,7 +942,7 @@
|
||||
* // => true
|
||||
*/
|
||||
function isDate(value) {
|
||||
return toString.call(value) == dateClass;
|
||||
return value instanceof Date || toString.call(value) == dateClass;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1190,7 +1190,7 @@
|
||||
// fallback for older versions of Chrome and Safari
|
||||
if (isFunction(/x/)) {
|
||||
isFunction = function(value) {
|
||||
return toString.call(value) == funcClass;
|
||||
return value instanceof Function || toString.call(value) == funcClass;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1304,7 +1304,7 @@
|
||||
* // => true
|
||||
*/
|
||||
function isRegExp(value) {
|
||||
return toString.call(value) == regexpClass;
|
||||
return value instanceof RegExp || toString.call(value) == regexpClass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user