.merge() - DarthJDG/Mangler.js GitHub Wiki
Copies properties of an object into all items. It can also merge arrays of objects.
.merge(source)| Parameter | Type | Default | Description |
|---|---|---|---|
| source | Object Array.Object |
The object or array of objects from which to copy properties. |
Returns the mangler object itself for chaining.
Copies all top-level properties of source object into all objects in the .items[ ] array. The source object will not be modified in any way. If a property with the same name already exists in the destination object, it will be overwritten.
Note that Mangler.merge() does not create a deep copy of the source object, e.g. if you copy a property .prop with an object reference, then both source.prop and destination.prop will reference the same object. To create a deep copy, see Mangler.clone().
Calling .merge() is the same as calling Mangler.merge() with the .items array as the destination parameter. See Mangler.merge() for more information and examples.
m = Mangler({ a: 1 });
o = { b: 1 };
// The following calls are identical
m.merge(o);
Mangler.merge(m.items, o);