Skip to content

ConstancyImmutability primitives for JavaScript

From freeze to isolated snapshots — 7 defense levels, zero dependencies, TypeScript-first.

Choose the right tool

NeedUse
Freeze existing object in placefreezeShallow, deepFreeze
Prevent mutation via one referenceimmutableView
Create immutable data copysnapshot
Prevent any mutable reference leakvault
Harden plain config objectsecureSnapshot
Add integrity fingerprinttamperEvident
Verify immutability at runtimeisDeepFrozen, assertDeepFrozen
Detect builtin tamperingcheckRuntimeIntegrity

Not sure which to pick? See Choose the Right Model for a decision flowchart and comparison matrix.

Why constancy?

Most "freeze" libraries stop at Object.freeze. Constancy gives you 7 levels of protection — from shallow freeze to tamper-evident vaults with hash verification — and defends against prototype pollution, builtin override attacks, and reference extraction. Zero dependencies, SLSA 3 provenance, fuzz-tested, 228+ tests at 98% coverage.

Released under the MIT License.