fix: update isFunction (#20912)

pull/20920/head
好多大米 2021-04-08 17:13:39 +08:00 committed by GitHub
parent 0606cb8f96
commit 0418a47148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import Vue from 'vue';
export function isString(obj) { export function isString(obj) {
return Object.prototype.toString.call(obj) === '[object String]'; return Object.prototype.toString.call(obj) === '[object String]';
} }
@ -10,11 +12,25 @@ export function isHtmlElement(node) {
return node && node.nodeType === Node.ELEMENT_NODE; return node && node.nodeType === Node.ELEMENT_NODE;
} }
export const isFunction = (functionToCheck) => { /**
* - Inspired:
* https://github.com/jashkenas/underscore/blob/master/modules/isFunction.js
*/
let isFunction = (functionToCheck) => {
var getType = {}; var getType = {};
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
}; };
if (typeof /./ !== 'function' && typeof Int8Array !== 'object' && (Vue.prototype.$isServer || typeof document.childNodes !== 'function')) {
isFunction = function(obj) {
return typeof obj === 'function' || false;
};
}
export {
isFunction
};
export const isUndefined = (val)=> { export const isUndefined = (val)=> {
return val === void 0; return val === void 0;
}; };