0.1.3 • Published 3 years ago

@x82-softworks/clone-merge v0.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@x82-softworks/clone-merge

A recursive merge utility

Recursively merges objects together. Can be configured to use deep merging, as well as shallow copying as well. The returned object is a new object to prevent mutable read/write problemns

Autogenerated docs

https://x82-open-source.gitlab.io/npm/clone-merge

Usage

import cloneMerge,{ DEEP,SHALLOW } from '@x82-softworks/clone-merge';

let std = cloneMerge(
{
    x: {
        y:1,
        z:3
    }
},
{
    x:{
        y:2,
    }
});
/* {
    x:{
        y:2
    }
} */

let deep = cloneMerge(DEEP,
{
    x: {
        y:1,
        z:3
    }
},
{
    x:{
        y:2,
    }
});
/* {
    x:{
        y:2,
        z:3
    }
} */


 let x = 
 {
    foo: 'bar'
};
let shallow = lib(SHALLOW, {
    x
}, {
    q: {
        y: 2
    }
});
// shallow.x === x shallow equality