Skip to main content
Module

x/rambda/mergeDeepRight.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { type } from './type'
export function mergeDeepRight(target, source){ if (arguments.length === 1){ return sourceHolder => mergeDeepRight(target, sourceHolder) }
const willReturn = JSON.parse(JSON.stringify(target))
Object.keys(source).forEach(key => { if (type(source[ key ]) === 'Object'){ if (type(target[ key ]) === 'Object'){ willReturn[ key ] = mergeDeepRight(target[ key ], source[ key ]) } else { willReturn[ key ] = source[ key ] } } else { willReturn[ key ] = source[ key ] } })
return willReturn}