mirror of
https://github.com/mue/mue.git
synced 2026-06-12 19:48:57 +02:00
Add merge function from @eartharoid
Co-authored-by: Isaac Saunders <contact@eartharoid.me>
This commit is contained in:
@@ -8,7 +8,7 @@ import Navbar from './components/widgets/navbar/Navbar';
|
||||
import SettingsFunctions from './modules/helpers/settings';
|
||||
import { ToastContainer } from 'react-toastify';
|
||||
import Modal from 'react-modal';
|
||||
import merge from 'deepmerge';
|
||||
import merge from './modules/helpers/merge';
|
||||
|
||||
// Modals are lazy loaded as the user won't use them every time they open a tab
|
||||
const Main = React.lazy(() => import('./components/modals/Main'));
|
||||
|
||||
19
src/modules/helpers/merge.js
Normal file
19
src/modules/helpers/merge.js
Normal file
@@ -0,0 +1,19 @@
|
||||
export default function deepmerge(...objects) {
|
||||
let target = {};
|
||||
|
||||
const merge = (obj) => {
|
||||
for (let prop in obj) {
|
||||
if (obj.hasOwnProperty(prop)) {
|
||||
if (typeof obj[prop] === 'object') {
|
||||
target[prop] = deepmerge(target[prop], obj[prop]);
|
||||
} else {
|
||||
target[prop] = obj[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
objects.forEach(object => merge(object));
|
||||
|
||||
return target;
|
||||
}
|
||||
Reference in New Issue
Block a user