circle-assign is a simple deep object assign function and can be used in nodejs and the browser
$ npm install --save circle-assign
circleAssign(target, ...sources)
const circleAssign = require('circle-assign');
import circleAssign from 'circle-assign';
<script
type="application/javascript"
src="https://cdn.jsdelivr.net/npm/circle-assign@2.0.0/dist/circle-assign.min.js"
/>
const a = {
language: 'javascript',
features: {
recursive: true,
size: 'small'
}
};
const b = {
language: 'JavaScript',
opensource: true,
features: {
size: '~1.3kb',
canMergeFunctions: true
}
};
const c = {
coolFunc: () => {
console.log('Much wow');
}
};
console.log(circleAssign(a, b, c));
Output
{
language: "JavaScript",
opensource: true,
features: {
recursive: true,
size: "~1.3kb",
canMergeFunctions: true
},
coolFunc: () => {
console.log('Much wow');
}
}