soft-extend
Version:
Non-destructive extend. Just appends new properties to an object, keeping old ones.
26 lines (19 loc) • 626 B
Markdown
# Soft-extend <a href="UNLICENSE"><img src="http://upload.wikimedia.org/wikipedia/commons/6/62/PD-icon.svg" width="20"/></a>
Extend any object softly, i. e. do not replace existing properties, just append the new ones.
```js
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);
}
```
[](https://nodei.co/npm/soft-extend/)