MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / isPartialMatch

Function isPartialMatch

packages/db/src/buffers/partial-json-match.ts:7–42  ·  view source on GitHub ↗
(source: any, partial: any)

Source from the content-addressed store, hash-verified

5 * @returns boolean indicating if the partial object matches the source
6 */
7export function isPartialMatch(source: any, partial: any): boolean {
8 // Handle null/undefined cases
9 if (partial === null || partial === undefined) {
10 return source === partial;
11 }
12
13 // If partial is not an object, do direct comparison
14 if (typeof partial !== 'object') {
15 return source === partial;
16 }
17
18 // If source is null/undefined but partial is an object, no match
19 if (source === null || source === undefined) {
20 return false;
21 }
22
23 // Check each property in partial
24 for (const key in partial) {
25 if (
26 Object.prototype.hasOwnProperty.call(partial, key) &&
27 partial[key] !== undefined
28 ) {
29 // If property doesn't exist in source, no match
30 if (!(key in source)) {
31 return false;
32 }
33
34 // Recursively check nested objects
35 if (!isPartialMatch(source[key], partial[key])) {
36 return false;
37 }
38 }
39 }
40
41 return true;
42}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected