soft-extend

Non-destructive extend. Just appends new properties to an object, keeping old ones.

Usage no npm install needed!

<script type="module">
  import softExtend from 'https://cdn.skypack.dev/soft-extend';
</script>

README

Soft-extend

Extend any object softly, i. e. do not replace existing properties, just append the new ones.

var sextend = require('soft-extend');

var defaults = {
    intensity: 100,
    hold: true,
    coords: {
        x: 0,
        y: 0
    },
    data: [1, 2, 3]
}

//the very common use-case
function MyClass(options){
    this.options = sextend(options || {}, defaults);
}

NPM