lodash/lodash — pull request #716 by jabclab (2014-09-19 15:41:42+00:00)
Title: Memoized safe for objects

Making `_.memoize` safe for arbitrary objects.

Previously we ran into issues when running something similar to:

```js
var memoized = _.memoize(function (person) {
return 'hello ' + person.name;
});

var first = memoized({ name: 'Jake' });
// hello Jake

var second = memoized({ name: 'Jon' });
// hello Jake
```

Upon inspection of the `memoized.cache` `Object` we found that the keys were effectively the `.toString()` value of the key, hence `Object`s not being safe.

I have modified the cache so it is now an `Array` which has the following schema:

```
var memoized = _.memoize(function (person) {
return 'hello ' + person.name;
});

var first = memoized({ name: 'Jake' });
var second = memoized({ name: 'Jon' });

var cache = memoized.cache;
// [
// { key: { name: 'Jake', cached: 'hello Jake' } },
// { key: { name: 'Jon', cached: 'hello Jon' } }
// ]
```

In order to the deep comparison of arbitrary objects `_.identity` is used.

:smile: