{"id":13065,"library":"dequal","title":"dequal: Deep Equality Utility","description":"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.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/lukeed/dequal","tags":["javascript","deep","deep-equal","equality","typescript"],"install":[{"cmd":"npm install dequal","lang":"bash","label":"npm"},{"cmd":"yarn add dequal","lang":"bash","label":"yarn"},{"cmd":"pnpm add dequal","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Since v2.0.0, 'dequal' is a named export for both ESM and TypeScript. Default imports will fail.","wrong":"import dequal from 'dequal';","symbol":"dequal","correct":"import { dequal } from 'dequal';"},{"note":"Since v2.0.0, 'dequal' is a named export for CommonJS environments. Requiring the default export will fail.","wrong":"const dequal = require('dequal');","symbol":"dequal","correct":"const { dequal } = require('dequal');"},{"note":"The 'dequal/lite' entrypoint also uses a named export. This version has reduced feature support but is smaller.","wrong":"import dequal from 'dequal/lite';","symbol":"dequal (lite)","correct":"import { dequal } from 'dequal/lite';"}],"quickstart":{"code":"import { dequal } from 'dequal';\n\n// Basic equality checks\nconsole.log(dequal(1, 1)); //=> true\nconsole.log(dequal({}, {})); //=> true\nconsole.log(dequal('foo', 'foo')); //=> true\nconsole.log(dequal([1, 2, 3], [1, 2, 3])); //=> true\nconsole.log(dequal(null, null)); //=> true\nconsole.log(dequal(NaN, NaN)); //=> true\n\n// Complex object comparison\nconst obj1 = { a: 1, b: [{ c: 2, d: 'foo' }], e: new Set([1, 2]) };\nconst obj2 = { a: 1, b: [{ c: 2, d: 'foo' }], e: new Set([2, 1]) }; // Set order doesn't matter\nconsole.log(dequal(obj1, obj2)); //=> true\n\n// Demonstrating inequality\nconsole.log(dequal(1, '1')); //=> false\nconsole.log(dequal(null, undefined)); //=> false\nconsole.log(dequal({ a: 1, b: [2, 3] }, { a: 1, b: [2, 5] })); //=> false\nconsole.log(dequal(/foo/i, /bar/g)); //=> false\n\n// Array order matters\nconsole.log(dequal([1, 2], [2, 1])); //=> false","lang":"typescript","description":"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."},"warnings":[{"fix":"Update imports to `import { dequal } from 'dequal'` for ESM/TypeScript or `const { dequal } = require('dequal')` for CommonJS.","message":"The package migrated from a default export to a named export. Code using `import dequal from 'dequal'` or `const dequal = require('dequal')` will break.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"If IE9+ compatibility is required, use `dequal/lite` instead. Be aware of its feature limitations for certain complex types.","message":"Support for Internet Explorer (IE9+) was dropped in the main `dequal` bundle.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always use the main `dequal` import (`import { dequal } from 'dequal'`) when comparing these complex types to ensure correct behavior.","message":"The `dequal/lite` entrypoint is a smaller, more performant bundle but lacks support for comparing `Set`, `Map`, `ArrayBuffer`, `TypedArray`s, and `DataView` types.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"If array element order should not matter for your comparison, sort the arrays before passing them to `dequal` or use a different comparison logic.","message":"While object key order does not affect equality, the order of elements within arrays *does* matter for `dequal` to return true.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure this behavior aligns with your expectations when comparing `Set` or `Map` instances. If referential equality is desired, compare the instances directly without `dequal`.","message":"For `Set` and `Map` types, `dequal` uses value equality for their contents and keys, respectively. This might behave differently than other deep comparison libraries that sometimes rely on referential equality for these structures.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `const dequal = require('dequal');` to `const { dequal } = require('dequal');`","cause":"Attempting to use `dequal` as a default export in CommonJS after v2.0.0.","error":"TypeError: dequal is not a function"},{"fix":"Change `import dequal from 'dequal';` to `import { dequal } from 'dequal';`","cause":"Attempting to use `dequal` as a default export in ESM/TypeScript after v2.0.0.","error":"TypeError: Cannot read properties of undefined (reading 'dequal')"},{"fix":"Ensure you are importing the full `dequal` library: `import { dequal } from 'dequal';` not `from 'dequal/lite';`","cause":"Likely comparing `Set` or `Map` types using `dequal/lite`, which does not support these types.","error":"dequal(setA, setB) returns false, but they look identical"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}