function judgeTypeFnCreator (type) {
const toString = Object.prototype.toString
return function isType (o) {
return toString.call(o) === `[object ${type}]`
}
}
const isFunc = judgeTypeFnCreator('Function')
const isUndef = judgeTypeFnCreator('Undefined')
const isArray = judgeTypeFnCreator('Array')
const isString = judgeTypeFnCreator('String')
const isObject = judgeTypeFnCreator('Object')
const isNumber = judgeTypeFnCreator('Number')
function deepAssign(to, from) {
for (let key in from) {
if (!to[key] || typeof to[key] !== 'object') {
to[key] = from[key]
} else {
deepAssign(to[key], from[key])
}
}
}