123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- "use strict";
- function isObjectNotArray(value) {
- return typeof value === "object" && value !== null && !Array.isArray(value);
- }
- function deepMergeObjects(first, second) {
- if (second === void 0) {
- return first;
- }
- if (!isObjectNotArray(first) || !isObjectNotArray(second)) {
- return second;
- }
- const result = { ...first, ...second };
- for (const key of Object.keys(second)) {
- if (Object.prototype.propertyIsEnumerable.call(first, key)) {
- result[key] = deepMergeObjects(first[key], second[key]);
- }
- }
- return result;
- }
- function deepMergeArrays(first, second) {
- if (!first || !second) {
- return second || first || [];
- }
- return [
- ...first.map((value, i) => deepMergeObjects(value, i < second.length ? second[i] : void 0)),
- ...second.slice(first.length)
- ];
- }
- module.exports = { deepMergeArrays };
|