ixfx
    Preparing search index...

    Function changedObjectDataFields

    • Returns the changed fields from A -> B. It's assumed that A and B have the same shape. ie. returns an object that only consists of fields which have changed in B compared to A.

      const a = { msg: `hi`, v: 10 };

      changedObjectDataFields(a, { msg: `hi`, v: 10 }); // {}
      changedObjectDataFields(a, { msg: `hi!!`, v: 10 }); // { msg: `hi!!` }
      changedObjectDataFields(a, { msg: `hi!!` }); // { msg: `hi!!`, v: undefined }

      If B has additional or removed fields, this is considered an error.

      If a field is an array, the whole array is returned, rather than a diff.

      Parameters

      • a: object
      • b: object

      Returns Record<string, unknown> | object[]