This commit is contained in:
lijianyou
2025-09-30 15:00:32 +08:00
parent 1b262f06b8
commit b4e759cf69
202 changed files with 22035 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
/**
* 初始化目标值为 undefined 的属性
* @param target 目标对象
* @param dft 默认值对象
*/
export function initUndefined<T extends Record<string, any>, K extends keyof T>(target: T, dft: Required<Pick<T, K>>) {
(Object.keys(dft) as K[]).forEach((key) => (target[key] = target[key] ?? dft[key]));
}