compare
Does a type or deep value comparison of two objects.
Signature
compare(a: {}, b: {}, compareValues: boolean): boolean
Parameters
Name | Type | Optional | Description |
---|---|---|---|
a | {} | No | Specifies the first variable. |
b | {} | No | Specifies the second variable. |
compareValues | boolean | No | Specifies if the values or just the structure needs to be compared. |
Return value
Returns true
if the objects are identical.
Example
import { compare } from "@tripetto/runner";
compare({ a: 1, b: 2 }, { a: 1, b: 3 }, false); // Returns `true`
compare({ a: 1, b: 2 }, { a: 1, c: 3 }, false); // Returns `false`
compare({ a: 1, b: 2 }, { a: 1, b: 3 }, true); // Returns `false`
compare({ a: 1, b: 2 }, { a: 1, b: 2 }, true); // Returns `true`