All files merge.ts

100% Statements 14/14
100% Branches 7/7
100% Functions 2/2
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  21x 1x 16x 16x 6x 1x   5x     10x     16x   1x  
// a simple object merge function implementation
export const isobj = x => typeof x === 'object' && !Array.isArray(x) && x !== null
const merge = (target, source) => {
	for (const key of Object.keys(source)) {
		if (isobj(source[key])) {
			if (!(key in target)) {
				target[key] = source[key]
			} else {
				merge(target[key], source[key])
			}
		} else {
			target[key] = source[key]
		}
	}
	return target
}
export default merge