Instantly share code, notes, and snippets.

Embed
What would you like to do?
List of immutable libraries

A lot of people mentioned other immutable JS libraries after reading my post. I thought it would be good to make a list of available ones.

There are two types of immutable libraries: simple helpers for copying JavaScript objects, and actual persistent data structure implementations. My post generally analyzed the tradeoffs between both kinds of libraries and everything applies to the below libraries in either category.

Libraries are sorted by github popularity.

Persistent Data Structures w/structural sharing

  • immutable.js - Facebook's implementation with a JS-like API
  • mori - ClojureScript's persistent data structures exported to JS
  • ancient-oak - Not sure about this one. It doesn't seem to fully implement efficient structural sharing (tries, etc) like the above libraries, but it claims to implement parts of it and I see some implementation of a data structure in there. It also copies object props onto the data structure so you can access them like obj.property, which is neat but might have a perf cost.

Other libraries built on top of immutable.js: typed-immutable and immstruct

Immutable helpers (simply shallow copy JS objects)

@herrstucki

This comment has been minimized.

herrstucki commented Oct 6, 2015

FWIW, I also made a immutable helper library https://github.com/herrstucki/sprout/ . It tries to preserve strict equality as much as possible (in the case a value doesn't actually change); something I haven't seen being done in other similar libraries.

@ghengeveld

This comment has been minimized.

ghengeveld commented Oct 7, 2015

I think updeep should be in the second list.

@jlongster

This comment has been minimized.

Owner

jlongster commented Oct 14, 2015

Added both of those libs. Thanks!

@mbektimirov

This comment has been minimized.

mbektimirov commented Oct 25, 2015

Take a look at Morearty, Om inspired cursors library.

@AlexGalays

This comment has been minimized.

AlexGalays commented Jan 27, 2016

immutability not strictly enforced, but tiny footprint: https://github.com/AlexGalays/immupdate

@YoruNoHikage

This comment has been minimized.

YoruNoHikage commented Mar 3, 2016

scour.js could be in the list as well, I think. :)

@winkler1

This comment has been minimized.

winkler1 commented Mar 3, 2016

Icedam freezes data in dev mode at the Redux connector handoff. Vanilla JS data structures.

@guigrpa

This comment has been minimized.

guigrpa commented Jun 19, 2016

Might want to add timm to the second list. Here's a blog post comparing it to Immutable.js and seamless-immutable. Timm is tiny and has good performance (benchmarks are also available at the first link).

@ghost

This comment has been minimized.

ghost commented Nov 10, 2016

I am looking for a immutability lib, that just deep freezes all the objects and arrays, but doesnt provide any helper methods to operate on those. Any idea?

@PaulBurridge-kcom

This comment has been minimized.

PaulBurridge-kcom commented Dec 8, 2016

@moe I have used deep-freeze-strict

@polytypic

This comment has been minimized.

polytypic commented Mar 19, 2017

If you need to manipulate complex data structures in JavaScript in an immutable manner, you might also want to check out my partial.lenses library, which is a comprehensive, high-performance optics library for JavaScript. Here is the preface:

Lenses are basically an abstraction for simultaneously specifying operations to update and query immutable data structures. Lenses are highly composable and can be efficient. This library provides a collection of partial isomorphisms, lenses, and traversals, collectively known as optics, for manipulating JSON and users can write new optics for manipulating non-JSON objects, such as Immutable.js collections. A partial lens can view optional data, insert new data, update existing data and remove existing data and can, for example, provide defaults and maintain required data structure parts.

The library also comes with comprehensive documentation.

@andrewgrewell

This comment has been minimized.

andrewgrewell commented Aug 7, 2017

Structy is a easy to use declarative data structure library

@fredrikekelund

This comment has been minimized.

fredrikekelund commented Aug 21, 2017

setimmutable works like lodash.set, but copies objects/arrays as needed along the way. Thinnest possible layer for simplifying updates to immutable deep data structures!

@emmanueltouzery

This comment has been minimized.

emmanueltouzery commented Oct 2, 2017

I created prelude.ts which would fit in the list too.

@rchod

This comment has been minimized.

rchod commented Nov 7, 2018

Immer should be on the list https://github.com/mweststrate/immer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment