1 | export function mergeFuncProps(p1, p2) {
|
2 | const p1Keys = Object.keys(p1);
|
3 | const p2Keys = Object.keys(p2);
|
4 | const keys = new Set([...p1Keys, ...p2Keys]);
|
5 | const res = {};
|
6 | keys.forEach(key => {
|
7 | const p1Value = p1[key];
|
8 | const p2Value = p2[key];
|
9 | if (typeof p1Value === 'function' && typeof p2Value === 'function') {
|
10 | res[key] = function (...args) {
|
11 | p1Value(...args);
|
12 | p2Value(...args);
|
13 | };
|
14 | } else {
|
15 | res[key] = p1Value || p2Value;
|
16 | }
|
17 | });
|
18 | return res;
|
19 | } |
\ | No newline at end of file |