4 ms·
How does this compare to https://github.com/facebook/immutable-js https://github.com/facebook/immutable-js ? Has anybody used both?
by evv 12y ago
How does this compare to https://github.com/facebook/immutable-js https://github.com/facebook/immutable-js ? Has anybody used both?
- drawkbox 12y agoYou have to convert to and from js objects with the facebook one (immutable-js), although lots of the js api calls are the same push/set/slice etc. This one is directly on js objects (seamless-immutable).
- Sonata 12y agoFrom what I can see, seamless-immutable basically just enforces immutability on native JavaScript data structures. Immutable.js on the other hand, implements full persistent data structures, which give much better time complexity guarantees about important operations. Immutable.js also has a rich API designed for manipulating immutable data structures and uses lazy evaluation for methods like map, filter and concat, which really improves performance when chaining chose operations.
- pimlottc 12y agoThey both mimic the standard Array/Map/Set methods but differ in how they handle mutating methods like push and set. In Facebook's version, these functions return a new immutable instance with the values changed appropriately, while this one throws an error. It also provides a few new methods to combine/transform existing immutables. I like the look of this one better. IMHO Facebook's approach will lead to confusion and subtle errors when their immutables are mixed up with normal objects and arrays. Personally I think this is think that's an unwise decision that will lead to confusion and subtle errors.