gpbl / denormalizr

Denormalize data normalized with normalizr
https://www.npmjs.com/package/denormalizr
MIT License
228 stars 24 forks source link

Add support for immutable-js #12

Closed jeffcarbs closed 8 years ago

jeffcarbs commented 8 years ago

Adds support for immutable-js without actually requiring it as a dependency.

Support is handled by using simple getIn, setIn methods that defer to the immutable implementations if the object is immutable otherwise implement the same behavior on plain javascript objects/arrays. immutable-js is required as a dev dependency since it's needed for specs. I just copied the existing specs and adapted them to work with immutable.

One thing to note (which I added to the README): Circular references is something that immutable-js does not support (and does not plan to support). When a circular reference is reached, the non-denormalized copy is returned. So:

// The nested article only contains a reference to the author by ID
denormalized.author.articles[0].author === 1
gpbl commented 8 years ago

Well done! Thank you 👍