Which is Better JavaScript Deep Equality Libraries?
fast-deep-equal vs deep-equal vs deep-eql vs lodash.isequal vs is-equal
1 Year
fast-deep-equaldeep-equaldeep-eqllodash.isequalis-equal
What's JavaScript Deep Equality Libraries?

Deep equality libraries are used in JavaScript to compare complex objects, arrays, and values to determine if they are equivalent. These libraries provide various algorithms to handle deep comparisons, which are necessary when dealing with nested structures. They help developers ensure that data integrity is maintained when performing operations like state updates, data validation, or data synchronization in applications.

NPM Package Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
fast-deep-equal47,833,4841,888-334 years agoMIT
deep-equal21,642,83177690.3 kB4a year agoMIT
deep-eql13,194,85910823.9 kB214 months agoMIT
lodash.isequal11,199,78559,696-1088 years agoMIT
is-equal79,03660122 kB2a year agoMIT
Feature Comparison: fast-deep-equal vs deep-equal vs deep-eql vs lodash.isequal vs is-equal

Performance

  • fast-deep-equal: fast-deep-equal is the fastest option among these libraries, focusing on performance by using a minimalistic approach to deep comparisons, making it ideal for high-performance applications.
  • deep-equal: deep-equal is optimized for speed and is generally faster than deep-eql, making it suitable for applications where performance is important but complexity is moderate.
  • deep-eql: deep-eql is designed to handle complex comparisons, including circular references, but may incur a performance penalty in scenarios with large data structures due to its comprehensive checks.
  • lodash.isequal: lodash.isequal is efficient and well-optimized, but it may not be as fast as fast-deep-equal. However, it benefits from being part of the Lodash ecosystem, which can enhance overall performance in projects that utilize multiple Lodash functions.
  • is-equal: is-equal offers decent performance, striking a balance between speed and functionality, making it suitable for most applications without extreme performance demands.

Complexity Handling

  • fast-deep-equal: fast-deep-equal is designed for performance and can handle typical nested structures efficiently, but it may not support circular references or custom equality checks.
  • deep-equal: deep-equal can handle most complex structures but may struggle with circular references. It is best suited for simpler comparisons where deep nesting is not a primary concern.
  • deep-eql: deep-eql excels at handling complex data structures, including nested objects and arrays, as well as circular references. It is particularly useful in scenarios where data integrity is crucial, such as testing frameworks.
  • lodash.isequal: lodash.isequal is robust in handling complex data structures, including circular references, making it a versatile choice for applications that require deep equality checks.
  • is-equal: is-equal provides good support for nested structures but may not handle circular references as effectively as deep-eql. It is a solid choice for general-purpose comparisons.

Ease of Use

  • fast-deep-equal: fast-deep-equal is easy to implement and provides a simple interface, making it ideal for developers who prioritize speed and efficiency in their comparisons.
  • deep-equal: deep-equal is simple to use and requires minimal configuration, making it accessible for developers who need quick comparisons without extensive setup.
  • deep-eql: deep-eql has a straightforward API, making it easy to integrate into existing projects. Its comprehensive nature allows developers to perform deep comparisons with minimal setup.
  • lodash.isequal: lodash.isequal integrates seamlessly with other Lodash functions, providing a familiar interface for developers already using Lodash, enhancing usability.
  • is-equal: is-equal offers a user-friendly API that is easy to understand and implement, making it suitable for developers of all skill levels.

Customization

  • fast-deep-equal: fast-deep-equal is not designed for customization; it focuses solely on performance and standard deep equality checks, which may not suit all use cases.
  • deep-equal: deep-equal does not support custom equality checks, focusing instead on standard comparisons, which may limit its flexibility in certain scenarios.
  • deep-eql: deep-eql allows for custom equality checks, enabling developers to define their own comparison logic for specific data types, which is beneficial in complex applications.
  • lodash.isequal: lodash.isequal allows for some customization through Lodash's utility functions, providing a balance between flexibility and ease of use.
  • is-equal: is-equal provides basic customization options but does not offer the extensive flexibility found in deep-eql, making it less suitable for highly specialized requirements.

Library Size

  • fast-deep-equal: fast-deep-equal is extremely lightweight and optimized for performance, making it ideal for applications where every byte counts.
  • deep-equal: deep-equal is very lightweight, making it an excellent choice for projects where minimizing bundle size is a priority.
  • deep-eql: deep-eql is relatively lightweight, but its comprehensive feature set may increase the size slightly compared to simpler libraries.
  • lodash.isequal: lodash.isequal is part of the larger Lodash library, which can increase the overall size of your application if you're only using this function, but it offers extensive utility.
  • is-equal: is-equal has a moderate size, providing a good balance between functionality and footprint, suitable for most applications.
How to Choose: fast-deep-equal vs deep-equal vs deep-eql vs lodash.isequal vs is-equal
  • fast-deep-equal: Opt for fast-deep-equal if performance is your top priority. It provides a highly optimized algorithm for deep comparisons and is particularly useful in performance-sensitive applications where speed is crucial.
  • deep-equal: Select deep-equal for a lightweight and straightforward solution that performs deep comparisons without additional overhead. It is suitable for most use cases where performance is not a primary concern.
  • deep-eql: Choose deep-eql if you need a comprehensive solution that handles complex data structures, including support for circular references and custom equality checks. It is ideal for testing scenarios where deep comparison is critical.
  • lodash.isequal: Choose lodash.isequal if you are already using the Lodash library and want to maintain consistency in your codebase. It provides a robust solution with additional utility functions, making it ideal for projects that require extensive data manipulation.
  • is-equal: Use is-equal for a simple and effective deep comparison library that is easy to integrate into existing projects. It offers a balance between performance and functionality, making it suitable for general-purpose use.
README for fast-deep-equal

fast-deep-equal

The fastest deep equal with ES6 Map, Set and Typed arrays support.

Build Status npm Coverage Status

Install

npm install fast-deep-equal

Features

  • ES5 compatible
  • works in node.js (8+) and browsers (IE9+)
  • checks equality of Date and RegExp objects by value.

ES6 equal (require('fast-deep-equal/es6')) also supports:

  • Maps
  • Sets
  • Typed arrays

Usage

var equal = require('fast-deep-equal');
console.log(equal({foo: 'bar'}, {foo: 'bar'})); // true

To support ES6 Maps, Sets and Typed arrays equality use:

var equal = require('fast-deep-equal/es6');
console.log(equal(Int16Array([1, 2]), Int16Array([1, 2]))); // true

To use with React (avoiding the traversal of React elements' _owner property that contains circular references and is not needed when comparing the elements - borrowed from react-fast-compare):

var equal = require('fast-deep-equal/react');
var equal = require('fast-deep-equal/es6/react');

Performance benchmark

Node.js v12.6.0:

fast-deep-equal x 261,950 ops/sec ±0.52% (89 runs sampled)
fast-deep-equal/es6 x 212,991 ops/sec ±0.34% (92 runs sampled)
fast-equals x 230,957 ops/sec ±0.83% (85 runs sampled)
nano-equal x 187,995 ops/sec ±0.53% (88 runs sampled)
shallow-equal-fuzzy x 138,302 ops/sec ±0.49% (90 runs sampled)
underscore.isEqual x 74,423 ops/sec ±0.38% (89 runs sampled)
lodash.isEqual x 36,637 ops/sec ±0.72% (90 runs sampled)
deep-equal x 2,310 ops/sec ±0.37% (90 runs sampled)
deep-eql x 35,312 ops/sec ±0.67% (91 runs sampled)
ramda.equals x 12,054 ops/sec ±0.40% (91 runs sampled)
util.isDeepStrictEqual x 46,440 ops/sec ±0.43% (90 runs sampled)
assert.deepStrictEqual x 456 ops/sec ±0.71% (88 runs sampled)

The fastest is fast-deep-equal

To run benchmark (requires node.js 6+):

npm run benchmark

Please note: this benchmark runs against the available test cases. To choose the most performant library for your application, it is recommended to benchmark against your data and to NOT expect this benchmark to reflect the performance difference in your application.

Enterprise support

fast-deep-equal package is a part of Tidelift enterprise subscription - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.

Security contact

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.

License

MIT