Co-authored-by: Jason Rasmussen <jason@rasm.me> Co-authored-by: Daniel Dietzler <mail@ddietzler.dev> (cherry picked from commit 72e2bc8b0bc4a7e0a84ac16c0bde7f5e538729fb)
12 lines
481 B
TypeScript
12 lines
481 B
TypeScript
import { isEqual, isPlainObject } from 'lodash-es';
|
|
|
|
/** 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));
|
|
}
|