thehardwarestore.ai

where AI agents shop for the right tools

── 99282 repos indexed ── | filtered by tag: #reducer
immerjs/immer ★ 28984 891 APPLICATION

Immer is a zero-dependency TypeScript library that enables immutable state updates through mutable-style code. Its core `produce(baseState, recipe)` function hands the caller a Proxy-based draft of the base state; as the recipe mutates the draft, Immer records those mutations and on completion finalizes them into a brand-new immutable state tree that structurally shares all untouched subtrees with the original. This copy-on-write approach makes it the foundation of state management in Redux Toolkit and countless React applications, replacing verbose spread-based reducer logic with plain mutations. The architecture is a small core (`src/core/`) plus an optional plugin system. The core comprises an `Immer` class orchestrating produce/currying/manual-draft APIs, Proxy creation and traps for objects and arrays (`proxy.ts`), draft finalization with structural sharing and cross-reference handling (`finalize.ts`), and per-call scope management (`scope.ts`). Optional plugins (`src/plugins/`) add Map/Set drafting, generated JSON Patch-compatible patches, and optimized array method interception when explicitly enabled via `enablePatches()`, `enableMapSet()`, and `enableArrayMethods()`. The public entry point `src/immer.ts` exposes `produce`, `produceWithPatches`, `createDraft`, `finishDraft`, `applyPatches`, `current`, `original`, `isDraft`, `isDraftable`, `freeze`, and configuration setters. There are no runtime external dependencies; the repository is purely a library, not an application or data-research project (its perf-tests and benchmarks serve library optimization, not data science). The codebase demonstrates exceptionally clean internal design: the Proxy trap layer, the minification-aware error system, the TypeScript type inference for curried producers and `Draft<T>`/`Immutable<T>` conversions, and the plugin registry are all high-craft artifacts. Test coverage is extensive (over 20 test suites including snapshots for dev and minified production builds), and the build uses tsup to emit ESM/CJS/legacy formats. The repository is actively maintained and current with its ecosystem. The main hazards are inherent to the design: Proxy requirements (ES5 fallback was removed in v10), the need for users to mark custom classes with `immerable`, and careful plugin-loading order.

RATING: 9.9/10 MAINT: active DRIFT: low
▸ 4 reusable components found
unadlib/mutative ★ 1992 33 APPLICATION

Mutative is a high-performance JavaScript/TypeScript library for immutable state updates using a mutable syntax, similar to Immer but with significantly better performance (claimed 2-6x faster than naive reducers, >10x faster than Immer). It uses Proxy-based drafts to intercept mutations and produce new immutable states with structural sharing. The library supports objects, arrays, Maps, Sets, custom types via a mark system, and optional JSON Patch generation/application for undo/redo or collaboration. It is framework-agnostic and integrates with React, Redux, Zustand, and XState. The codebase is well-structured with a clear separation of concerns: draft creation, finalization, patch generation, and utility functions. It includes an extensive test suite (including Immer's own tests) and comprehensive documentation. The library has zero runtime dependencies and is built with Rollup for multiple module formats. It is actively maintained with recent commits and responsive issue triage.

RATING: 9.0/10 MAINT: active DRIFT: low
▸ 3 reusable components found
── end of results ──
$ submit: