mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 19:37:49 +00:00
Fix _.isFunction and _.isNative for Safari 8.
This commit is contained in:
@@ -7377,9 +7377,9 @@
|
|||||||
return typeof value == 'function' || false;
|
return typeof value == 'function' || false;
|
||||||
}
|
}
|
||||||
// fallback for older versions of Chrome and Safari
|
// fallback for older versions of Chrome and Safari
|
||||||
if (isFunction(/x/)) {
|
if (isFunction(/x/) || !Uint8Array || !isFunction(Uint8Array)) {
|
||||||
isFunction = function(value) {
|
isFunction = function(value) {
|
||||||
return typeof value == 'function' && toString.call(value) == funcClass;
|
return toString.call(value) == funcClass;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7461,7 +7461,7 @@
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isNative(value) {
|
function isNative(value) {
|
||||||
if (isFunction(value)) {
|
if (typeof value == 'function' || toString.call(value) == funcClass) {
|
||||||
return reNative.test(fnToString.call(value));
|
return reNative.test(fnToString.call(value));
|
||||||
}
|
}
|
||||||
return (value && typeof value == 'object' &&
|
return (value && typeof value == 'object' &&
|
||||||
|
|||||||
13
test/test.js
13
test/test.js
@@ -6464,6 +6464,19 @@
|
|||||||
strictEqual(_.isFunction(slice), true);
|
strictEqual(_.isFunction(slice), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should return `true` for typed array constructors', 1, function() {
|
||||||
|
var expected = _.map(typedArrays, function(type) {
|
||||||
|
return toString.call(root[type]) == '[object Function]';
|
||||||
|
});
|
||||||
|
|
||||||
|
var actual = _.map(typedArrays, function(type) {
|
||||||
|
var Ctor = root[type];
|
||||||
|
return Ctor ? _.isFunction(Ctor) : false;
|
||||||
|
});
|
||||||
|
|
||||||
|
deepEqual(actual, expected);
|
||||||
|
});
|
||||||
|
|
||||||
test('should return `false` for non functions', 11, function() {
|
test('should return `false` for non functions', 11, function() {
|
||||||
var expected = _.map(falsey, _.constant(false));
|
var expected = _.map(falsey, _.constant(false));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user