# 介绍
ljc-wjsljc是一款极简的前端utils工具库,该库包含了前端工作中常用的utils函数。
该库采用TypeScript构建
部分源码展示:
function extend<T, U>(to: T, ...from: U[]): T & U {
for (let i = 0, len = from.length; i < len; i++) {
for (const key in from[i]) {
;(to as T & U)[key] = from[i][key] as any
}
}
return to as T & U
}
function deepMerge(...objs: any[]): any {
const result = Object.create(null)
objs.forEach(obj => {
if (obj) {
Object.keys(obj).forEach(key => {
const val = obj[key]
if (isPlainObject(val)) {
if (isPlainObject(result[key])) {
result[key] = deepMerge(result[key], val)
} else {
result[key] = deepMerge(val) // 新递归
}
} else {
result[key] = val
}
})
}
})
return result
}
快速上手 →