Recursively merges and guards your objects against unwanted tampering.
npm install sphinx> Recursively merges and guards your objects against unwanted tampering.
- only change the values for properties that exist on the destination object.
- only change the values for properties that are of the same type as the destination object.
```
npm install --save sphinx
`javascript
var sphinx = require( "sphinx" );
var destination = { foo: "bar" };
var source = { foo: "qux" };
var merged = sphinx.merge( destination, source );
//=> { foo: "qux" }
`
- Trying to add a property that doesn't exist on the destination object.
`javascript
var destination = { foo: "bar" };
var source = { baz: "qux" };
var merged = sphinx.merge( destination, source );
//=> [Error: Property "baz" does not exist on destination object]
`
- Trying to merge a property of a mismatched type.
`javascript
var destination = { foo: "bar" };
var source = { foo: 1 };
var merged = sphinx.merge( destination, source );
//=> [TypeError: Expected property "foo" to be a [object String]]
`
Name | Type | Argument | Default | Description
---------------|-----------|--------------|---------|------------
destination | Object | | null | The destination object. Object
source | | | null` | The source object.