dequal is a minimalist utility for performing deep equality checks on JavaScript values. Currently at version 2.0.3, it offers a stable and performant solution for comparing various data types, including primitives, objects, arrays, functions, regular expressions, dates, Sets, Maps, TypedArrays, and DataViews. The library is actively maintained, with recent patches addressing TypeScript type conditions and "nodenext" resolver support. A key differentiator is its exceptionally small bundle size (304B to 489B gzipped) and the provision of two modes: the full `dequal` for comprehensive type support and `dequal/lite` for a smaller footprint that omits support for Sets, Maps, ArrayBuffers, TypedArrays, and DataViews, but maintains IE9+ compatibility. It emphasizes value equality for Set and Map contents/keys, while noting that object key order is irrelevant but array element order is significant.
npm install dequalVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates various deep equality checks using the main `dequal` function, covering primitive values, objects, arrays, and sets, and illustrating both equal and unequal comparisons. It highlights the library's behavior regarding array order.
Update imports to `import { dequal } from 'dequal'` for ESM/TypeScript or `const { dequal } = require('dequal')` for CommonJS.If IE9+ compatibility is required, use `dequal/lite` instead. Be aware of its feature limitations for certain complex types.
Always use the main `dequal` import (`import { dequal } from 'dequal'`) when comparing these complex types to ensure correct behavior.If array element order should not matter for your comparison, sort the arrays before passing them to `dequal` or use a different comparison logic.
Ensure this behavior aligns with your expectations when comparing `Set` or `Map` instances. If referential equality is desired, compare the instances directly without `dequal`.
Change `const dequal = require('dequal');` to `const { dequal } = require('dequal');`Change `import dequal from 'dequal';` to `import { dequal } from 'dequal';`Ensure you are importing the full `dequal` library: `import { dequal } from 'dequal';` not `from 'dequal/lite';`No dependency data recorded yet.