mirror of https://github.com/mue/mue.git
Add merge function from @eartharoid
Co-authored-by: Isaac Saunders <contact@eartharoid.me>
This commit is contained in:
parent
d42f69ae95
commit
5836849ab9
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "mue",
|
||||
"private": true,
|
||||
"author": "David \"ohlookitsderpy\" Ralph <contact@derpyenterprises.org> (https://derpyenterprises.org)",
|
||||
"author": "David \"ohlookitsderpy\" Ralph <me@davidjcralph.co.uk> (https://davidjcralph.co.uk)",
|
||||
"description": "Fast, open and free-to-use new tab page for modern browsers.",
|
||||
"repository": {
|
||||
"url": "github:mue/mue"
|
||||
|
@ -16,7 +16,6 @@
|
|||
"@fontsource/roboto": "^4.2.1",
|
||||
"@material-ui/core": "4.11.3",
|
||||
"@material-ui/icons": "4.11.2",
|
||||
"deepmerge": "^4.2.2",
|
||||
"react": "17.0.1",
|
||||
"react-clock": "^3.0.0",
|
||||
"react-color-gradient-picker": "^0.1.2",
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue