mirror of
https://github.com/bitwarden/browser
synced 2025-12-23 19:53:43 +00:00
* created guard to clear search text when navigating between tabs * removed reset filter from from vault list filter component on destroy and move to guard renamed guard to clear vault state * Fixed bug on chip select when comparing complex objects moved compare values function to utils * Added comment for future reference * moved compare values to a seperate file * fixed lint issue
28 lines
813 B
TypeScript
28 lines
813 B
TypeScript
/**
|
|
* Performs deep equality check between two values
|
|
*
|
|
* NOTE: This method uses JSON.stringify to compare objects, which may return false
|
|
* for objects with the same properties but in different order. If order-insensitive
|
|
* comparison becomes necessary in future, consider updating this method to use a comparison
|
|
* that checks for property existence and value equality without regard to order.
|
|
*/
|
|
export function compareValues<T>(value1: T, value2: T): boolean {
|
|
if (value1 == null && value2 == null) {
|
|
return true;
|
|
}
|
|
|
|
if (value1 && value2 == null) {
|
|
return false;
|
|
}
|
|
|
|
if (value1 == null && value2) {
|
|
return false;
|
|
}
|
|
|
|
if (typeof value1 !== "object" || typeof value2 !== "object") {
|
|
return value1 === value2;
|
|
}
|
|
|
|
return JSON.stringify(value1) === JSON.stringify(value2);
|
|
}
|