mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-01 06:49:32 +08:00
22 lines
444 B
TypeScript
22 lines
444 B
TypeScript
|
type RecordType = Record<string, any>;
|
||
|
|
||
|
function extendsObject<T extends RecordType>(...list: T[]) {
|
||
|
const result: RecordType = { ...list[0] };
|
||
|
|
||
|
for (let i = 1; i < list.length; i++) {
|
||
|
const obj = list[i];
|
||
|
if (obj) {
|
||
|
Object.keys(obj).forEach((key) => {
|
||
|
const val = obj[key];
|
||
|
if (val !== undefined) {
|
||
|
result[key] = val;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
export default extendsObject;
|