MCPcopy
hub / github.com/rjsf-team/react-jsonschema-form / getChangedFields

Function getChangedFields

packages/utils/src/getChangedFields.ts:25–41  ·  view source on GitHub ↗
(a: unknown, b: unknown)

Source from the content-addressed store, hash-verified

23 * console.log(changedFields); // Output: ['age']
24 */
25export default function getChangedFields(a: unknown, b: unknown): string[] {
26 const aIsPlainObject = isPlainObject(a);
27 const bIsPlainObject = isPlainObject(b);
28 // If strictly equal or neither of them is a plainObject returns an empty array
29 if (a === b || (!aIsPlainObject && !bIsPlainObject)) {
30 return [];
31 }
32 if (aIsPlainObject && !bIsPlainObject) {
33 return keys(a);
34 }
35 if (!aIsPlainObject && bIsPlainObject) {
36 return keys(b);
37 }
38 const unequalFields = keys(pickBy(a as object, (value, key) => !deepEquals(value, get(b, key))));
39 const diffFields = difference(keys(b), keys(a));
40 return [...unequalFields, ...diffFields];
41}

Callers 2

Calls 1

getFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…