A javascript library for working with objects
Deeply superimposes two or more items on each other.
Notes:
- Undefined values will not overwrite defined values
- Array order is maintained
Returns: *
- The resulting object
Param | Type | Default | Description |
---|---|---|---|
args | * |
two or more items to superimpose on each other. Each item is superimposed on the item before it. | |
[mutateFirst] | Boolean |
false |
If a final argument of true is provided, then the first object will be mutated in place and returned. |
Example
import { superimpose } from 'object-agent';
const thing1 = {
a: 1,
c: {
d: 3
e: 5
},
f: [1, 2]
};
const thing2 = {
b: 2,
c: {
d: 4
},
f: [3]
};
const result = superimpose(thing1, thing2);
// => {
// a: 1,
// b: 2,
// c: {
// d: 4,
// e: 5
// },
// f: [3, 2]
//}
console.log(result === thing1);
// => false