gorillatron-extend

Merge properties from a list of objects into one new object.

extend

Merge properties from two objects into one new object.

$ component install gorillatron/extend

Like jquery extend, but doesnt mutate passed objects, only returns a fresh object with the extended properties.

 
var defaults = {
  hide: false,
  delay: 1500,
  css: {
    color: 'blue'
  }
}
 
var settings = extend(true, defaults,{
  delay: 1700,
  css: {
    border: '1px solid red'
  }
})
 
expect(settings).to.eql({
  hide: false,
  delay: 1700,
  css: {
    color: 'blue',
    border: '1px solid red'
  }
})
 

MIT