mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2026-02-06 11:17:36 +00:00
spread syntax improvement
This commit is contained in:
parent
b18b855d58
commit
e90f286abd
@ -239,16 +239,14 @@ class EmulatorJS {
|
||||
this.volume = (typeof this.config.volume === "number") ? this.config.volume : 0.5;
|
||||
if (this.config.defaultControllers) {
|
||||
// Merge user config with defaults instead of replacing
|
||||
for (const player in this.config.defaultControllers) {
|
||||
if (!this.defaultControllers[player]) {
|
||||
this.defaultControllers[player] = {};
|
||||
}
|
||||
for (const button in this.config.defaultControllers[player]) {
|
||||
this.defaultControllers[player][button] = Object.assign(
|
||||
{},
|
||||
this.defaultControllers[player][button] || {},
|
||||
this.config.defaultControllers[player][button]
|
||||
);
|
||||
for (const [player, buttons] of Object.entries(this.config.defaultControllers)) {
|
||||
this.defaultControllers[player] = this.defaultControllers[player] || {};
|
||||
|
||||
for (const [button, config] of Object.entries(buttons)) {
|
||||
this.defaultControllers[player][button] = {
|
||||
...(this.defaultControllers[player][button] || {}),
|
||||
...config
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user