isObjectMatch()function

isObjectMatch(left: L | R, right: R, recursor: Match = isEqual): left is L & R
ParamType
leftL
R
The object to check and narrow. required
rightR
The object whose props left must contain. required
recursorMatch
Function that checks each prop of the object.
- Defaults to isEqual() to check strict equality of the properties.
- Use isDeepEqual() as the recursor to check to check deep equality of the properties. Defaults to isEqual
Return
left is L & R
true if left contains every prop of right with matching values.

Are two objects partially equal based on their own props?

  • left must have every property present in right
  • left may have have excess properties not present in right

Examples

isObjectMatch({ a: 1, b: 2 }, { a: 1 }) // true