chore: add isFunction utils and improve isObject

This commit is contained in:
陈嘉涵
2020-01-19 20:13:50 +08:00
parent 3a4107ef49
commit 4b54ec6a18
11 changed files with 32 additions and 31 deletions

View File

@@ -7,13 +7,16 @@ export const isServer: boolean = Vue.prototype.$isServer;
export function noop() {}
export function isDef(value: any): boolean {
return value !== undefined && value !== null;
export function isDef(val: any): boolean {
return val !== undefined && val !== null;
}
export function isObj(x: any): boolean {
const type = typeof x;
return x !== null && (type === 'object' || type === 'function');
export function isFunction(val: unknown): val is Function {
return typeof val === 'function';
}
export function isObject(val: any): val is Record<any, any> {
return val !== null && typeof val === 'object';
}
export function get(object: any, path: string): any {