MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / getObjectDiff

Function getObjectDiff

web/dashboard/src/utils/index.ts:51–75  ·  view source on GitHub ↗
(
	obj1: Record<string, unknown>,
	obj2: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

49};
50
51export const getObjectDiff = (
52 obj1: Record<string, unknown>,
53 obj2: Record<string, unknown>,
54): string[] => {
55 const diff = Object.keys(obj1).reduce((result, key) => {
56 if (!Object.prototype.hasOwnProperty.call(obj2, key)) {
57 result.push(key);
58 } else if (
59 _.isEqual(obj1[key], obj2[key]) ||
60 (obj1[key] === null && obj2[key] === '') ||
61 (obj1[key] &&
62 Array.isArray(obj1[key]) &&
63 (obj1[key] as unknown[]).length === 0 &&
64 obj2[key] === null)
65 ) {
66 const resultKeyIndex = result.indexOf(key);
67 if (resultKeyIndex >= 0) {
68 result.splice(resultKeyIndex, 1);
69 }
70 }
71 return result;
72 }, Object.keys(obj2));
73
74 return diff;
75};
76
77export const validateEmail = (email: string) => {
78 if (!email || email === '') return true;

Callers 1

saveHandlerFunction · 0.90

Calls 1

callMethod · 0.80

Tested by

no test coverage detected