All files clone.js

100% Statements 8/8
88.88% Branches 8/9
100% Functions 2/2
100% Lines 8/8

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    22x 22x 69x 12x 12x   57x     22x       6x  
// Credits to : Andrew Dupont - http://andrewdupont.net/2009/08/28/deep-extending-objects-in-javascript/
export function deepExtend(destination, source) {
    destination = destination || {};
    for (const property in source) { // for-in is necessary
        if (source[property] && source[property].constructor && source[property].constructor === Object) {
            destination[property] = destination[property] || {};
            deepExtend(destination[property], source[property]);
        } else {
            destination[property] = source[property];
        }
    }
    return destination;
}
 
export function clone(object) {
    return deepExtend({}, object);
}