lowcode-engine/packages/utils/src/clone-enumerable-property.ts
2023-11-13 13:00:38 +08:00

23 lines
469 B
TypeScript

const excludePropertyNames = [
'$$typeof',
'render',
'defaultProps',
'props',
'length',
'prototype',
'name',
'caller',
'callee',
'arguments',
];
export function cloneEnumerableProperty(target: any, origin: any, excludes = excludePropertyNames) {
const compExtraPropertyNames = Object.keys(origin).filter(d => !excludes.includes(d));
compExtraPropertyNames.forEach((d: string) => {
(target as any)[d] = origin[d];
});
return target;
}