From fc66b376cb3a2c73843cc882d500cfd743c0790e Mon Sep 17 00:00:00 2001 From: sijanec Date: Sun, 17 May 2020 00:13:40 +0200 Subject: dist should work, TODO: minify and bundle --- dist/js/lib/mergedeep.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 dist/js/lib/mergedeep.js (limited to 'dist/js/lib/mergedeep.js') diff --git a/dist/js/lib/mergedeep.js b/dist/js/lib/mergedeep.js new file mode 100644 index 0000000..a56aa1d --- /dev/null +++ b/dist/js/lib/mergedeep.js @@ -0,0 +1,31 @@ +// https://stackoverflow.com/questions/27936772/how-to-deep-merge-instead-of-shallow-merge +/** + * Simple object check. + * @param item + * @returns {boolean} + */ +function isObject(item) { + return (item && typeof item === 'object' && !Array.isArray(item)); +} + +/** + * Deep merge two objects. + * @param target + * @param ...sources + */ +function mergeDeep(target, ...sources) { + if (!sources.length) return target; + const source = sources.shift(); + + if (isObject(target) && isObject(source)) { + for (const key in source) { + if (isObject(source[key])) { + if (!target[key]) Object.assign(target, { [key]: {} }); + mergeDeep(target[key], source[key]); + } else { + Object.assign(target, { [key]: source[key] }); + } + } + } + return mergeDeep(target, ...sources); +} -- cgit v1.2.3 From cfedc91453b67e79202730e7cf4197df24631379 Mon Sep 17 00:00:00 2001 From: sijanec Date: Wed, 20 May 2020 13:33:51 +0200 Subject: fixed install script --- dist/js/lib/mergedeep.js | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 dist/js/lib/mergedeep.js (limited to 'dist/js/lib/mergedeep.js') diff --git a/dist/js/lib/mergedeep.js b/dist/js/lib/mergedeep.js deleted file mode 100644 index a56aa1d..0000000 --- a/dist/js/lib/mergedeep.js +++ /dev/null @@ -1,31 +0,0 @@ -// https://stackoverflow.com/questions/27936772/how-to-deep-merge-instead-of-shallow-merge -/** - * Simple object check. - * @param item - * @returns {boolean} - */ -function isObject(item) { - return (item && typeof item === 'object' && !Array.isArray(item)); -} - -/** - * Deep merge two objects. - * @param target - * @param ...sources - */ -function mergeDeep(target, ...sources) { - if (!sources.length) return target; - const source = sources.shift(); - - if (isObject(target) && isObject(source)) { - for (const key in source) { - if (isObject(source[key])) { - if (!target[key]) Object.assign(target, { [key]: {} }); - mergeDeep(target[key], source[key]); - } else { - Object.assign(target, { [key]: source[key] }); - } - } - } - return mergeDeep(target, ...sources); -} -- cgit v1.2.3 From 7820ea23532aa6ffa3611d8379681aa44a3f3864 Mon Sep 17 00:00:00 2001 From: sijanec Date: Wed, 20 May 2020 14:12:06 +0200 Subject: # --- dist/js/lib/mergedeep.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 dist/js/lib/mergedeep.js (limited to 'dist/js/lib/mergedeep.js') diff --git a/dist/js/lib/mergedeep.js b/dist/js/lib/mergedeep.js new file mode 100644 index 0000000..a56aa1d --- /dev/null +++ b/dist/js/lib/mergedeep.js @@ -0,0 +1,31 @@ +// https://stackoverflow.com/questions/27936772/how-to-deep-merge-instead-of-shallow-merge +/** + * Simple object check. + * @param item + * @returns {boolean} + */ +function isObject(item) { + return (item && typeof item === 'object' && !Array.isArray(item)); +} + +/** + * Deep merge two objects. + * @param target + * @param ...sources + */ +function mergeDeep(target, ...sources) { + if (!sources.length) return target; + const source = sources.shift(); + + if (isObject(target) && isObject(source)) { + for (const key in source) { + if (isObject(source[key])) { + if (!target[key]) Object.assign(target, { [key]: {} }); + mergeDeep(target[key], source[key]); + } else { + Object.assign(target, { [key]: source[key] }); + } + } + } + return mergeDeep(target, ...sources); +} -- cgit v1.2.3 From 8cc2b856a47f7b1881171914147e6ddca7a8a02b Mon Sep 17 00:00:00 2001 From: sijanec Date: Wed, 20 May 2020 21:17:06 +0200 Subject: testing minification with jsmin --- dist/js/lib/mergedeep.js | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'dist/js/lib/mergedeep.js') diff --git a/dist/js/lib/mergedeep.js b/dist/js/lib/mergedeep.js index a56aa1d..fa2403d 100644 --- a/dist/js/lib/mergedeep.js +++ b/dist/js/lib/mergedeep.js @@ -1,31 +1,4 @@ -// https://stackoverflow.com/questions/27936772/how-to-deep-merge-instead-of-shallow-merge -/** - * Simple object check. - * @param item - * @returns {boolean} - */ -function isObject(item) { - return (item && typeof item === 'object' && !Array.isArray(item)); -} -/** - * Deep merge two objects. - * @param target - * @param ...sources - */ -function mergeDeep(target, ...sources) { - if (!sources.length) return target; - const source = sources.shift(); - - if (isObject(target) && isObject(source)) { - for (const key in source) { - if (isObject(source[key])) { - if (!target[key]) Object.assign(target, { [key]: {} }); - mergeDeep(target[key], source[key]); - } else { - Object.assign(target, { [key]: source[key] }); - } - } - } - return mergeDeep(target, ...sources); -} +function isObject(item){return(item&&typeof item==='object'&&!Array.isArray(item));} +function mergeDeep(target,...sources){if(!sources.length)return target;const source=sources.shift();if(isObject(target)&&isObject(source)){for(const key in source){if(isObject(source[key])){if(!target[key])Object.assign(target,{[key]:{}});mergeDeep(target[key],source[key]);}else{Object.assign(target,{[key]:source[key]});}}} +return mergeDeep(target,...sources);} \ No newline at end of file -- cgit v1.2.3