A tiny, zero-dependency library for treating frozen JavaScript objects as persistent immutable collections using structural sharing.
icepick is a tiny JavaScript library that enables immutable data structures by treating frozen objects as persistent collections. It solves the performance problem of deep cloning by using structural sharing, allowing efficient updates to large nested objects without mutating the original.
JavaScript developers working with immutable state, particularly in React applications or functional programming contexts where performance and plain object interoperability are priorities.
Developers choose icepick for its minimal footprint, zero dependencies, and seamless integration with plain JavaScript objects, offering a pragmatic alternative to heavier libraries like Immutable.js or seamless-immutable.
Utilities for treating frozen JavaScript objects as persistent immutable collections
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
At just 1kb minified and gzipped with zero dependencies, icepick adds minimal overhead to projects, as highlighted in the README.
It works with plain JavaScript objects and arrays, avoiding custom types for easy integration with third-party libraries, unlike Immutable.js.
Updates create partial clones using structural sharing, changing only affected branches to minimize performance overhead for nested structures.
Provides a chain method for fluent operations and includes immutable versions of common array methods like push and map for convenient updates.
The README admits that collections over 1000 elements can lead to performance problems due to the lack of trie-based structures like in Clojure.
Custom objects like Dates, Functions, or class instances are not frozen, leaving them vulnerable to mutation within otherwise immutable structures.
Developers must explicitly call freeze and thaw functions, adding boilerplate and risk of errors if immutability is accidentally bypassed.