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