4 ms·
I considered ImmutableJS a little while back. It's a great library but it makes you to a lot of work to go back and forth between native JS objects, and just ab
by coltonv 10y ago
I considered ImmutableJS a little while back. It's a great library but it makes you to a lot of work to go back and forth between native JS objects, and just abstracts you from the real objects underneath.
Instead I ended up just deepFreezing my data (only in development) and wrote a bunch of pure functions which perform all the important array/object functions but return a new array/object instead of mutating. It was a really great exercise in functional programming and I'd recommend it to anyone wanting immutable data and to understand immutable programming styles.
- Illniyar 10y agoThat's basically seamless-immutable . https://github.com/rtfeldman/seamless-immutable https://github.com/rtfeldman/seamless-immutable
- coltonv 10y agoPretty much yeah, just avoids tampering with the Object/Array prototype and gives you a chance to write the functions themselves. They are all just a few lines, so they make for great practice to write yourself.