Immutable persistent data collections for JavaScript that increase efficiency and simplify application development.
Immutable.js is a JavaScript library that provides persistent immutable data collections such as List, Map, Set, and Record. It solves the problem of tracking mutation and maintaining state in applications by ensuring data cannot be changed after creation, leading to simpler development and enabling efficient memoization and change detection.
JavaScript developers building applications with complex state management, particularly those using React or Flux architectures, and anyone needing predictable data flow with immutable collections.
Developers choose Immutable.js for its efficient structural sharing, which minimizes memory overhead, and its JavaScript-first API that integrates seamlessly with existing code while providing reliable value equality and lazy evaluation for performance.
Immutable persistent data collections for Javascript which increase efficiency and simplicity.
Uses hash map tries and vector tries to minimize memory overhead and copying, enabling persistent data structures that yield new data on mutation without full duplication, as highlighted in the introduction.
Provides .equals() and Immutable.is() for treating collections as values, allowing them to be used as keys in Maps or Sets, which is emphasized in the 'Equality treats Collections as Values' section.
Mirrors ES2015 Array, Map, and Set APIs for seamless interoperability, with examples in the README showing how to convert from raw JavaScript objects and arrays.
Seq allows efficient chaining of operations like map and filter without creating intermediate collections, demonstrated with examples such as oddSquares in the 'Lazy Seq' section.
withMutations enables performant local updates by creating temporary mutable copies, reducing overhead when applying multiple mutations, as shown in the batching examples.
While it mimics ES2015, Immutable.js introduces its own methods and paradigms, requiring developers to learn a new API rather than using native JavaScript, which can slow onboarding.
Converting between Immutable.js collections and plain JavaScript objects requires explicit calls like toJS() or fromJS(), adding boilerplate and potential errors in mixed codebases.
Value equality checks have O(N) time complexity for large collections, as noted in the 'Performance tradeoffs' section, which can be costly compared to reference equality.
Adds library overhead to application bundle size, which may not justify its use in lightweight projects or environments with strict size constraints.
Create the next immutable state by mutating the current one
Like Underscore, but lazier
ClojureScript's persistent data structures and supporting API from the comfort of vanilla JavaScript
JavaScript & TypeScript persistent and optionally immutable data tree with cursors.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.