MCPcopy Create free account
hub / github.com/EmNudge/watlings / matchObjectShape

Function matchObjectShape

web-build/src/runner.ts:53–63  ·  view source on GitHub ↗
(a: Record<string, unknown>, b: Record<string, unknown>)

Source from the content-addressed store, hash-verified

51}
52
53function matchObjectShape(a: Record<string, unknown>, b: Record<string, unknown>): boolean {
54 if (typeof a !== "object" || typeof b !== "object") return false;
55
56 const aKeys = Object.keys(a).sort();
57 const bKeys = Object.keys(b).sort();
58 if (aKeys.toString() !== bKeys.toString()) return false;
59
60 return aKeys.every(
61 (key) => a[key] !== undefined && b[key] !== undefined && matchesType(a[key], b[key]),
62 );
63}
64
65function throws(fn: () => unknown): boolean {
66 try {

Callers 1

matchesTypeFunction · 0.70

Calls 1

matchesTypeFunction · 0.85

Tested by

no test coverage detected