deepDiffObject()function
deepDiffObject(left: ImmutableObject, right: R): R | DeepPartial<R> | typeof SAME
| Param | Type | |
|---|---|---|
left | ImmutableObject | The old object. required |
right | R | The new/target object. required |
| Return | |
|---|---|
R | DeepPartial<R> | typeof SAME | Object containing the missing/updated properties that left needs to become right.- If the two values are deeply equal the SAME constant is returned.- If left isn't an object then the result can't be diffed so entire right is returned. |
Diff two objects to produce the transformation needed to transform left into right
- Only works on enumerable own keys (as returned by
Object.keys()). - Includes a constructor check — if
leftandrighthave different constructors they will not be merged andrightwill be returned (ensures arrays aren't compared with objects). - Properties that exist in
leftbut notright(i.e. have been deleted) are represented withundefined
Examples
deepDiffObject({ a: 1 }, { a: 1 }) // SAMEdeepDiffObject({ a: 1, b: 2 }, { a: 1 }) // { b: undefined }