What is @wry/equality?
@wry/equality is a lightweight JavaScript library designed to perform deep equality checks. It is particularly useful for comparing complex objects and arrays to determine if they are equivalent in value.
What are @wry/equality's main functionalities?
Deep Equality Check
This feature allows you to perform deep equality checks between two objects or arrays. The `equal` function will return `true` if the objects or arrays have the same structure and values.
const { equal } = require('@wry/equality');
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { a: 1, b: { c: 2 } };
console.log(equal(obj1, obj2)); // true
Shallow Equality Check
This feature allows you to perform shallow equality checks between two arrays. The `equal` function will return `true` if the arrays have the same elements in the same order.
const { equal } = require('@wry/equality');
const arr1 = [1, 2, 3];
const arr2 = [1, 2, 3];
console.log(equal(arr1, arr2)); // true
Other packages similar to @wry/equality
lodash.isequal
Lodash's `isEqual` function provides deep equality checks similar to @wry/equality. It is part of the larger Lodash utility library, which offers a wide range of utility functions for JavaScript. While `lodash.isequal` is more feature-rich, it also comes with the overhead of the entire Lodash library.
fast-deep-equal
The `fast-deep-equal` package is another lightweight library for deep equality checks. It is known for its performance and minimalistic approach, making it a good alternative to @wry/equality for projects that require high performance.
deep-equal
The `deep-equal` package is a popular choice for deep equality checks. It is robust and well-maintained, offering similar functionality to @wry/equality. However, it may not be as lightweight as @wry/equality.
@wry/equality
Structural equality checking for JavaScript values, with correct handling
of cyclic references, and minimal bundle size.