A Clojure(Script) library for concise, high-performance querying and transformation of nested and recursive data structures.
Specter is a Clojure and ClojureScript library designed for querying and transforming immutable, nested, and recursive data structures. It solves the problem of verbose and complex manual data manipulation in Clojure by providing a concise, composable API built around the concept of "navigators."
Clojure and ClojureScript developers who frequently work with complex nested data structures, such as those in data processing pipelines, configuration management, or tree-like data transformations.
Developers choose Specter for its combination of expressive power, performance, and simplicity—it allows sophisticated data manipulations in a few lines of code while maintaining or improving performance over manual Clojure operations.
Clojure(Script)'s missing piece
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Navigators can be combined into precise paths for data manipulation, enabling concise code for complex operations, such as transforming nested maps with `transform [MAP-VALS ALL MAP-VALS even?] inc data`.
Uses inline caching to rival hand-optimized code, with benchmarks showing 30% faster than `get-in` and 85% faster than `update-in` for common operations.
Transforms maintain original data structure types, like vectors staying vectors and sorted maps remaining sorted, as demonstrated in examples using `ALL` navigator.
Includes navigators for operations Clojure omits, such as `BEFORE-ELEM` for prepending to vectors, addressing edge cases not covered by built-in functions.
Supports efficient recursive queries on tree-like data and allows collecting values during transforms with `collect-one`, enabling context-aware manipulations without manual state management.
Requires alternative namespace declarations in ClojureScript, such as using `:as` or `:refer-macros`, because `:refer :all` is not allowed, adding friction for cross-platform projects.
Needs extra setup for clj-kondo to resolve unresolved var warnings, as indicated in the README, which complicates integration with static analysis tools.
Relies on macros like `defnav` for defining navigators, which can obscure error messages and make debugging and tooling support more challenging compared to pure functions.