Assert
isEql

Checks deeply if the given two values are equivalent.

It handles the circular references.

Other types are checked by their references, Eg: Function.

Related

Syntax

import { isEql } from '@opentf/std';
 
isEql(val1: unknown, val2: unknown): Boolean;

Examples

isEql({a: 1, b: 2}, {a: 1, b: 2}) //=> true
 
const mapA = new Map([
  ['a', 1],
  ['b', 2],
]);
const mapB = new Map([
  ['b', 2],
  ['a', 1],
]);
isEql(mapA, mapB); //=> false
 
const re = new RegExp('ab+c');
const re2 = new RegExp('ab+d');
isEql(re, re2); //=> false
 
const ta1 = new Uint8Array([42, 43]);
const ta2 = new Uint8Array([42, 43]);
const ta3 = new Uint8Array([42, 45]);
isEql(ta1, ta2); //=> true
isEql(ta2, ta3); //=> false

Try