documentcloud/underscore — pull request #652 by omnosis (2012-06-23 14:56:54+00:00)
Title: Add _.isSimilar(comparative, compared) function

Performs a deep comparison between the two objects to determine, if they are similar or not. Similarity means, that the compared object has all the keys as the comparative with the same type of the values, but can be any value. The comparative object contain specific string or instances to determine the type.

returns false
* compared dosen't have any key that comparative has. `{a:'a'} != {b:'b'}`
* compared has same key, but different type of the value `{a:1} != {a:'a'}`

Returns true:

* compared have the same key-value as the comparative. `{a:'a'} == {a:'a'}`
* compared have same key, same type, but different value as the comparative. `{a:'a'} == {a:'b'}`
* compared have more keys than comparative. `{a:'a'} == {a:'b', c:'d'}`

This feature is useful with json communication. To check each key-value exist in a json object is a torture.
For example I want to get a response like this:

```javascript
SomeData {
name:'Bob',
age: '35'
timeStamp: '562212545',
stuffs: {
car: 'Ford',
family: {
wife: 'Julia',
childrens: ['Peter','Jacob']
}
house: 'Big'
}
}
```

When i want to check if it formatted well, I have to check each property is defined, and if the value is good.
With `_.isSimilar()` I only have to make a Proto object and compare to the specific object.