Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jasonkuhrt
Copy link
Owner

Summary

  • Add immutability utilities to Obj module: toImmutable, isImmutable, isMutable, inferImmutabilityMode, forwardImmutability
  • forwardImmutability validates invalid mut, imm combination with static error type and runtime throw
  • Group.by now returns frozen (immutable) group sets by default
  • Add Group.byMut for mutable group sets
  • Group.merge and Group.map use polymorphic dispatch based on input immutability

Breaking Changes

  • Group.by now returns immutable (frozen) group sets. Use Group.byMut for the previous mutable behavior.

Test plan

  • Type checks pass (pnpm check:types)
  • All tests pass (pnpm test)
  • New tests for immutability utilities in mutability.test.ts
  • Updated tests for Group module immutability behavior

Closes #96

@netlify
Copy link

netlify bot commented Nov 25, 2025

Deploy Preview for wollybeard-kit canceled.

Name Link
🔨 Latest commit a917498
🔍 Latest deploy log https://app.netlify.com/projects/wollybeard-kit/deploys/6925d0508875e50008f145b8

…ble by default

- Add Obj.toImmutable, isImmutable, isMutable, inferImmutabilityMode, forwardImmutability
- forwardImmutability validates mut+imm combination with static error and runtime throw
- Group.by now returns frozen group sets (use Group.byMut for mutable)
- Group.merge and Group.map use polymorphic dispatch based on input immutability
- Refactor Arr module to use forwardImmutability for consistent behavior

BREAKING CHANGE: Group.by now returns immutable (frozen) group sets
@jasonkuhrt jasonkuhrt force-pushed the feat/96-make-group-module-immutable-by branch from 3dfb837 to 0e96d8a Compare November 25, 2025 14:43
- toImmutable now creates a shallow copy then freezes (safer default)
- toImmutableMut freezes in place (explicit opt-in for mutation)
- Updated Arr and Group modules to use toImmutableMut for freshly
  created arrays to avoid unnecessary double-copy
Inverse of toImmutable - creates a shallow unfrozen copy of an object.
Since Object.freeze is one-way in JS, this always creates a new object.
Obj module:
- Rename toMutable → cloneToMut (clearer naming)
- Add clone() - preserves immutability state

Group module:
- Add clone() - structure-aware, preserves state
- Add cloneToMut() - structure-aware, always mutable
- Add toImmutable() - clone + deep freeze
- Add toImmutableMut() - deep freeze in place
- Dogfood toImmutableMut in by(), merge(), map()

Naming convention:
- *Mut suffix = mutates input in place
- *ToX suffix = transforms output to X state
Skip cloning if input is already frozen - assumes if top-level
is frozen, entire DS is frozen (reasonable contract in practice).
@jasonkuhrt jasonkuhrt merged commit 4a1fcf0 into main Nov 25, 2025
11 checks passed
@jasonkuhrt jasonkuhrt deleted the feat/96-make-group-module-immutable-by branch November 25, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Group module immutable by default with polymorphic dispatch

2 participants