ghost-portal/packages/react-api/src/util/isEqual.ts
Tarik Gul 384049fb6b
2025 (#11172)
* 2025

* update ci scripts to add access to scripts
2025-01-03 03:59:53 +02:00

17 lines
506 B
TypeScript

// Copyright 2017-2025 @polkadot/react-api authors & contributors
// SPDX-License-Identifier: Apache-2.0
function flatten (_key: string | null, value?: unknown): unknown {
return !value
? value
: (value as Record<string, unknown>).$$typeof
? ''
: Array.isArray(value)
? value.map((item) => flatten(null, item))
: value;
}
export function isEqual <T> (a?: T, b?: T): boolean {
return JSON.stringify({ test: a }, flatten) === JSON.stringify({ test: b }, flatten);
}