mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
16 lines
486 B
TypeScript
16 lines
486 B
TypeScript
|
|
import { isEqual, isPlainObject } from 'lodash';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Deeply clones and converts a class instance to a plain object.
|
||
|
|
*/
|
||
|
|
export function toPlainObject<T extends object>(obj: T): T {
|
||
|
|
return isPlainObject(obj) ? obj : structuredClone(obj);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Performs a deep comparison between objects, converting them to plain objects first if needed.
|
||
|
|
*/
|
||
|
|
export function isEqualObject(value: object, other: object): boolean {
|
||
|
|
return isEqual(toPlainObject(value), toPlainObject(other));
|
||
|
|
}
|