dequal
A tiny (304B to 489B gzipped), zero-dependency utility for deep equality checks in JavaScript.
Repository Health
Technical Analysis
dequal is a minimal deep-equality utility for JavaScript that compares any two values — primitives, Objects, Arrays, Dates, RegExps, Functions, class instances, Sets, Maps, ArrayBuffers, TypedArrays, and DataViews — for structural equality rather than reference equality. It ships as two builds: the full dequal (489 bytes gzipped) and a dequal/lite variant (304 bytes gzipped) that drops Set/Map/TypedArray/ArrayBuffer support for projects that don’t need it.
Under the hood it recursively dispatches on each value’s constructor rather than relying on JSON serialization or a fixed list of type checks, so it correctly handles NaN equality, key-order-independent object comparison, order-sensitive array comparison, and value-based (not referential) equality within Sets and Maps, including object keys inside a Map. Both builds ship as CommonJS, ESM, and (for the default build) UMD, with zero runtime dependencies.
What You Get
- Two entry points — the full
dequaland the ultra-minimaldequal/lite— so you only pay for the features you use - Zero runtime dependencies and sub-500-byte gzipped builds, published as CommonJS, ESM, and UMD
- Correct handling of NaN, key order in objects, item order in arrays, and value-based equality for Set/Map contents
- Full TypeScript type definitions included out of the box
Common Use Cases
- Comparing props or state snapshots in a UI framework to decide whether to re-render
- Asserting deep equality of complex fixtures in unit tests
- Memoizing expensive computations by comparing function arguments across calls
- Deduplicating arrays or objects fetched from an API before storing them
Under The Hood
Architecture
dequal is a single pure recursive function (src/index.js) that short-circuits on ===, then dispatches by comparing foo.constructor === bar.constructor and branching per type (Date, RegExp, Array, Set, Map, ArrayBuffer, DataView, typed arrays, plain objects), using a private find() helper to do value-based lookups when Set/Map keys are themselves objects. src/lite.js is not a thin wrapper around the default build but a deliberately separate, smaller reimplementation that omits Set/Map/TypedArray/ArrayBuffer handling — a real architectural trade-off where a correctness fix to the core walk must be applied in both files or the two modes silently diverge. There is no class, no configuration object, and no state; the entire surface area is one exported function per mode, which keeps the abstraction easy to reason about despite the duplication risk.
Tech Stack
The package has zero runtime dependencies. Its only devDependencies are bundt (a zero-config bundler that reads the modes field in package.json to emit dist/index.js (CJS), dist/index.mjs (ESM), and dist/index.min.js (UMD) for the default mode, and separate CJS/ESM output for lite), esm (lets import/export syntax run under Node’s classic CommonJS loader for tests), and uvu (a minimalist, fast test runner) with uvu/assert. Type definitions are hand-written in a single shared index.d.ts rather than generated from source. CI (GitHub Actions, .github/workflows/ci.yml) runs the test suite across Node 8, 10, 12, and 18, and on Node 18 also collects coverage via c8 and reports it to Codecov. The package is distributed to npm as a dual CJS/ESM package and to unpkg for direct browser use via the UMD build.
Code Quality
test/index.js and test/lite.js form an unusually thorough suite for a ~50-line function: scalars (including NaN, -0, Infinity), objects (key-order independence, undefined-vs-missing-key distinctions, null-prototype dictionaries), arrays (order sensitivity), Dates, RegExps (flag sensitivity), Functions (referential-only equality), classes (own properties vs. prototype members, getters, default constructor parameters), Maps and Sets (flat, nested, object-valued keys, insertion-order independence), and TypedArrays/Buffer/ArrayBuffer/DataView — the tests effectively double as the specification. There is no TypeScript compiler enforcing correctness (types are hand-authored) and no linter or formatter configuration in the repo, but the CI matrix spanning four Node versions plus coverage reporting is a solid quality signal for a project this small.
API Design
The public API is a single named export, dequal(foo, bar): boolean, with zero configuration and zero setup required. The README documents a clear compatibility matrix between the dequal and dequal/lite builds and includes benchmark comparisons against fast-deep-equal, lodash.isEqual, and Node’s built-in util.isDeepStrictEqual, giving consumers concrete grounds to choose a build. Bundled TypeScript definitions mean consumers get autocomplete and type-checking without an extra @types package. The one DX rough edge is the two-mode split itself — picking dequal/lite silently drops Set/Map/TypedArray support, which is documented but easy to miss.
Used by 8 apps in this directory
Ghost
CMS · Blogging
Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.
marimo
Developer Tools · Data Engineering
A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.
Payload CMS
Developer Tools · Blogging · CMS
The open-source, Next.js-native headless CMS that lives inside your /app folder and gives you a full TypeScript backend instantly.
Teable
Databases · No Code Platforms
A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.
Trigger.dev
Automation · AI Development · Developer Tools
Build and deploy fully-managed AI agents and background jobs in TypeScript — with no timeouts, durable retries, real-time observability, and elastic scaling built in.
Typebot
Developer Tools · AI Development · No Code Platforms
Build sophisticated chatbots visually, embed them anywhere without iframes, and own your data — fully self-hostable with a modular block system and 30+ integrations.
undb
No Code Platforms · Databases
Self-hosted no-code database and BaaS that lets you manage structured data visually with multi-database support, formula fields, and auto-generated OpenAPI endpoints.
Unleash
Developer Tools · Devops · Ab Testing Experimentation
The open-source feature management platform that lets you ship code to production and control who sees it — without redeploying.