UNPKG

@ylz/plugins

Version:

ylz plugins

33 lines (28 loc) 682 B
/** * 合并两个数组 * @param {*} obj1 * @param {*} obj2 */ export function deepMerge(obj1, obj2) { let key for (key in obj2) { obj1[key] = obj1[key] && obj1[key].toString() === '[object Object]' ? deepMerge(obj1[key], obj2[key]) : (obj1[key] = obj2[key]) } return obj1 } export const isArray = (val) => !!val && Array.isArray(val) export const isFunction = (val) => { return typeof val === 'function' } export const isObject = (obj) => { return obj === Object(obj) } export const isEmpty = (val) => { return val == null || !(Object.keys(val) || val).length } export const isString = (val) => { return typeof val === 'string' }