merge-config.js
837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export default function (defaultOptions, options, ...args) {
let resultOption = {
...defaultOptions,
getValueFromEvent: (e) => {
if (!e || !e.target) {
return e;
}
const { target } = e;
return target[resultOption.valuePropName];
},
};
if (typeof (options) === 'number') {
resultOption = {
...resultOption,
triggerMs: options,
};
if (typeof (args[1]) === 'boolean') {
resultOption = {
...resultOption,
uncontroll: args[1],
};
}
if (typeof (args[0]) === 'number') {
resultOption = {
...resultOption,
valuePropMs: args[0],
};
}
}
if (typeof (options) === 'object' && !Array.isArray(options)) {
resultOption = {
...resultOption,
...options,
};
}
return resultOption;
}