Sha256: 4c0cf821c0a53fa3fbe6279928428338a8ae515e9f2c93134317cedd3fd32a7d
Contents?: true
Size: 608 Bytes
Versions: 28
Compression:
Stored size: 608 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) => (Object.assign( {}, result, { [key]: deepMerge(target[key], source[key]) } )), {} ) } module.exports = deepMerge
Version data entries
28 entries across 28 versions & 5 rubygems