UNPKG

vuestic-ui

Version:
30 lines (29 loc) 903 B
const isObject = (obj) => obj && typeof obj === "object" && !Array.isArray(obj); const mergeDeep = (target, source) => { if (!isObject(target)) { target = {}; } Object.keys(source).forEach((key) => { const targetValue = target[key]; const sourceValue = source[key]; if (sourceValue instanceof RegExp || sourceValue instanceof Date) { target[key] = sourceValue; } else if (isObject(targetValue) && isObject(sourceValue)) { target[key] = mergeDeep(Object.create( Object.getPrototypeOf(targetValue), Object.getOwnPropertyDescriptors(targetValue) ), sourceValue); } else { target[key] = sourceValue; } }); return target; }; const mergeDeepMultiple = (...objects) => { return objects.reduce((acc, obj) => mergeDeep(acc, obj), {}); }; export { mergeDeepMultiple as a, mergeDeep as m }; //# sourceMappingURL=merge-deep.js.map