dbaumann/angular-identity-map — pull request #1 by pluff (2014-10-20 08:43:00+00:00)
Title: A little bit more work on angular-identity-map

Hi Dan.

Thanks for you great work on infrastructure and features of `identity-map` library! When I saw it I decided to use your code as base and rewrite it a bit to be more neat. Here you can review all the changes I've done so far. I'd recommend to review it commit by commit so you can track my line of thoughts better.

Anyway here is the changelog:
* The way how `identity-map` retrieves object class and object id is now configurable.
* Default functions (collectionKey, entityKey) replaced with project-agnostic and simple (entityType, entityId). If you still want to use `object.identity()` you should configure the service as described in README.
* `.update` method no longer type-casts updated entity. If your project uses type-casting you should do it before passing objects to identity map. Maybe it worth to implement configurable hook `before_map` so you don't have to type-cast every time explicitly.
* All tests were rewritten to coffeescript for convenience. New tests were added.
* `.detach` method introduced. It removed a single object from identity-map.
* identity-map works with objects as much as it can. all methods (except `.get`) now accept single `entity` object and returns mapped object, not a function. I.e. no `.set(Phone)(p)` syntax anymore. It's easier to use and also removes some inconsistency e.g.
```javascript
p = new Phone();
b = new Book();
IdentityMap.set(Phone)(b); // silently stores book "b" in collection "Phone".
```
* `.get` method can accept 1 or 2 parameters. `.get(object)` or `.get(entityId, entityClass)`.
* `.isMappable(obj)` predicate introduced. Returns true if "obj" can be stored in the map, otherwise returns false.
* `.set` method no longer accepts second argument. It also returns mapped entity instead of `undefined`.
* `.map(object)` method introduced. It's something similar to `.update_all_recursively`. It crawls through an object and tries to map everything inside. Works with objects as well as arrays.
* README updated with live demo plunkr. You can try it to see how new `.map` method works.

P.S. I'd really like to discuss other methods and your particular usecase of identity-map, but unfortunately I can't create issues in your repository. So if you are interested we can discuss it here. Just let me know.