Skip to content

Commit

Permalink
Simplifying 'this.merge()'
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jun 16, 2024
1 parent 37d834d commit b210aa2
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 48 deletions.
12 changes: 2 additions & 10 deletions dist/haro.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 15.2.1
* @version 15.2.2
*/
'use strict';

Expand Down Expand Up @@ -265,15 +265,7 @@ class Haro {
if (Array.isArray(a) && Array.isArray(b)) {
a = override ? b : a.concat(b);
} else if (a instanceof Object && b instanceof Object) {
this.each(Object.keys(b), i => {
if (Array.isArray(a[i]) && Array.isArray(b[i])) {
a[i] = override ? b[i] : a[i].concat(b[i]);
} else if (a[i] instanceof Object && b[i] instanceof Object) {
a[i] = this.merge(a[i], b[i], override);
} else {
a[i] = b[i];
}
});
this.each(Object.keys(b), i => (a[i] = this.merge(a[i], b[i], override)));
} else {
a = b;
}
Expand Down
12 changes: 2 additions & 10 deletions dist/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 15.2.1
* @version 15.2.2
*/
const STRING_COMMA = ",";
const STRING_EMPTY = "";
Expand Down Expand Up @@ -259,15 +259,7 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :
if (Array.isArray(a) && Array.isArray(b)) {
a = override ? b : a.concat(b);
} else if (a instanceof Object && b instanceof Object) {
this.each(Object.keys(b), i => {
if (Array.isArray(a[i]) && Array.isArray(b[i])) {
a[i] = override ? b[i] : a[i].concat(b[i]);
} else if (a[i] instanceof Object && b[i] instanceof Object) {
a[i] = this.merge(a[i], b[i], override);
} else {
a[i] = b[i];
}
});
this.each(Object.keys(b), i => (a[i] = this.merge(a[i], b[i], override)));
} else {
a = b;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/haro.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/haro.min.js.map

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions dist/haro.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 15.2.1
* @version 15.2.2
*/
(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.lru={}));})(this,(function(exports){'use strict';const STRING_COMMA = ",";
const STRING_EMPTY = "";
Expand Down Expand Up @@ -259,15 +259,7 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :
if (Array.isArray(a) && Array.isArray(b)) {
a = override ? b : a.concat(b);
} else if (a instanceof Object && b instanceof Object) {
this.each(Object.keys(b), i => {
if (Array.isArray(a[i]) && Array.isArray(b[i])) {
a[i] = override ? b[i] : a[i].concat(b[i]);
} else if (a[i] instanceof Object && b[i] instanceof Object) {
a[i] = this.merge(a[i], b[i], override);
} else {
a[i] = b[i];
}
});
this.each(Object.keys(b), i => (a[i] = this.merge(a[i], b[i], override)));
} else {
a = b;
}
Expand Down
Loading

0 comments on commit b210aa2

Please sign in to comment.