Sha256: 5d659496f93d4f86467a835af3933fd49d512b98c7c9aaf59adb1e7253455d54

Contents?: true

Size: 585 Bytes

Versions: 46

Compression:

Stored size: 585 Bytes

Contents

const {
  isObject, isArray, isEqual, isEmpty
} = require('./helpers')

const deepMerge = (target, source) => {
  if (isEmpty(target)) return source
  if (isEmpty(source)) return target
  if (isEqual(target, source)) return source
  if (isArray(target) && isArray(source)) return [...new Set([...target, ...source])]
  if (!(isObject(target) && isObject(source))) return source

  return [...Object.keys(target), ...Object.keys(source)].reduce(
    (result, key) => ({

      ...result,
      [key]: deepMerge(target[key], source[key])
    }),
    {}
  )
}

module.exports = deepMerge

Version data entries

46 entries across 45 versions & 9 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/utils/deep_merge.js
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/utils/deep_merge.js
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/package/utils/deep_merge.js
optimacms-0.1.61 spec/dummy/node_modules/@rails/webpacker/package/utils/deep_merge.js
jetpacker-0.7.0 package/utils/deep_merge.js
webpacker-5.4.4 package/utils/deep_merge.js
jetpacker-0.6.0 package/utils/deep_merge.js
disco_app-0.16.1 test/dummy/node_modules/@rails/webpacker/package/utils/deep_merge.js
disco_app-0.15.2 test/dummy/node_modules/@rails/webpacker/package/utils/deep_merge.js
disco_app-0.18.4 test/dummy/node_modules/@rails/webpacker/package/utils/deep_merge.js
disco_app-0.18.1 test/dummy/node_modules/@rails/webpacker/package/utils/deep_merge.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@rails/webpacker/package/utils/deep_merge.js
disco_app-0.14.0 test/dummy/node_modules/@rails/webpacker/package/utils/deep_merge.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@rails/webpacker/package/utils/deep_merge.js
webpacker-5.4.3 package/utils/deep_merge.js
webpacker-5.4.2 package/utils/deep_merge.js
webpacker-5.4.1 package/utils/deep_merge.js
webpacker-5.4.0 package/utils/deep_merge.js
webpacker-5.3.0 package/utils/deep_merge.js
webpacker-5.2.2 package/utils/deep_merge.js