@context-action/mutative
v0.8.8
Published
Mutative-based immutability and time-travel utilities for @context-action
Maintainers
Readme
@context-action/mutative
Mutative-backed immutable update, history, undo, and redo utilities for the Context-Action framework.
Installation
pnpm add @context-action/mutativeThe package uses the maintained @context-action/mutative-core runtime
internally. Install the core package directly only when the upstream-compatible
Mutative API is needed without the Context-Action adapter.
Adapter contract
produce(..., { freeze: true })forwards to the coreenableAutoFreezeoption.strictis a separate option and rejects non-draft replacement values; userawReturn()for an intentional raw replacement.produceWithPatchesreturns[state, patches, inversePatches]. Set changes use areplacepatch so undo/redo preserves insertion order.deepClonepreserves Map, Set, Date, and RegExp instances while recursively cloning their values.- Time-travel listeners receive the complete history and an optional transition-only patch list, which adapters use for precise path updates.
createTimeTravelforwardsenableAutoFreeze,strict, andpatchesOptionsto the core runtime. String patch paths are only valid for string properties and stringMapkeys; use array paths for numeric or object keys and Symbol properties.
License
Apache-2.0. See LICENSE.
