mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 04:11:57 +00:00
feat: add autoConfig/ better types for wrapperData
This commit is contained in:
19
lib/util/deepEqual.ts
Normal file
19
lib/util/deepEqual.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { object } from "ts-matches";
|
||||
|
||||
export function deepEqual(...args: unknown[]) {
|
||||
if (!object.test(args[args.length - 1])) return args[args.length - 1];
|
||||
const objects = args.filter(object.test);
|
||||
if (objects.length === 0) {
|
||||
for (const x of args) if (x !== args[0]) return false;
|
||||
return true;
|
||||
}
|
||||
if (objects.length !== args.length) return false;
|
||||
const allKeys = new Set(objects.flatMap((x) => Object.keys(x)));
|
||||
for (const key of allKeys) {
|
||||
for (const x of objects) {
|
||||
if (!(key in x)) return false;
|
||||
if (!deepEqual((objects[0] as any)[key], (x as any)[key])) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user