UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

27 lines 1.05 kB
export const mergeObjects = (target, ...sources) => { const result = Array.isArray(target) ? [] : { ...target }; for (const source of sources) { for (const key in source) { // eslint-disable-next-line no-prototype-builtins if (source.hasOwnProperty(key)) { if (typeof source[key] === 'object' && source[key] !== null) { if ( // eslint-disable-next-line no-prototype-builtins !result.hasOwnProperty(key) || typeof result[key] !== 'object' || result[key] === null) { result[key] = Array.isArray(source[key]) ? [] : {}; } result[key] = mergeObjects(result[key], source[key]); } else { result[key] = source[key]; } } } } return result; }; //# sourceMappingURL=mergeObjects.js.map